all repos — honk @ 3dfb48563b05ab72f0c7ca7ce5ab30d50cfa3f80

my fork of honk

little more error checking for new usernames
Ted Unangst tedu@tedunangst.com
Wed, 25 Nov 2020 21:50:51 -0500
commit

3dfb48563b05ab72f0c7ca7ce5ab30d50cfa3f80

parent

87915b2562e4c2d1d3953a20a2d176dab2b64e74

1 files changed, 14 insertions(+), 5 deletions(-)

jump to
M util.goutil.go

@@ -44,6 +44,7 @@ "log"

"net" "os" "os/signal" + "regexp" "strings" "golang.org/x/crypto/bcrypt"

@@ -107,12 +108,16 @@ }

} r := bufio.NewReader(os.Stdin) - err = createuser(db, r) + initblobdb() + + prepareStatements(db) + + err = createserveruser(db) if err != nil { log.Print(err) return } - err = createserveruser(db) + err = createuser(db, r) if err != nil { log.Print(err) return

@@ -153,9 +158,6 @@ setconfig("aboutmsg", "<h3>What is honk?</h3><p>Honk is amazing!")

setconfig("loginmsg", "<h2>login</h2>") setconfig("debug", 0) - initblobdb() - - prepareStatements(db) db.Close() fmt.Printf("done.\n") os.Exit(0)

@@ -306,6 +308,13 @@ }

name = name[:len(name)-1] if len(name) < 1 { return fmt.Errorf("that's way too short") + } + re_name := regexp.MustCompile("^[[:alnum:]]+$") + if !re_name.MatchString(name) { + return fmt.Errorf("alphanumeric only please") + } + if _, err := butwhatabout(name); err == nil { + return fmt.Errorf("user already exists") } pass, err := askpassword(r) if err != nil {