Prevent registration if user exists
alex wennerberg alex@alexwennerberg.com
Wed, 10 Feb 2021 20:18:22 -0800
1 files changed,
5 insertions(+),
0 deletions(-)
jump to
M
http.go
→
http.go
@@ -456,6 +456,11 @@ err := isOkUsername(username)
if err != nil { errors = append(errors, err.Error()) } + _, err = os.Stat(getUserDirectory(username)) + if !os.IsNotExist(err) { + // Don't allow user to create account if folder dne + errors = append(errors, "Invalid username") + } hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), 8) // TODO handle error if err != nil { serverError(w, err)