flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 8d930b0741c22b9c3453beae9d7892b1191be4e2
parent 0e234b1c3807aaf2a03d3e1755b90a6fc1e5e7d3
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 10 Feb 2021 20:18:22 -0800

Prevent registration if user exists

Diffstat:
Mhttp.go | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/http.go b/http.go @@ -456,6 +456,11 @@ func registerHandler(w http.ResponseWriter, r *http.Request) { 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)