all repos — flounder @ 77676e3b079aad7ed0d722533341e3dba562034a

A small site builder for the Gemini protocol

Fix bug with email login
alex wennerberg alex@alexwennerberg.com
Sat, 31 Oct 2020 00:01:59 -0700
commit

77676e3b079aad7ed0d722533341e3dba562034a

parent

dd52cd247d7bc0f86bbb64c9fa33f4355d6f9b7b

1 files changed, 4 insertions(+), 3 deletions(-)

jump to
M http.gohttp.go

@@ -230,11 +230,12 @@ } else if r.Method == "POST" {

r.ParseForm() name := r.Form.Get("username") password := r.Form.Get("password") - row := DB.QueryRow("SELECT password_hash, active, admin FROM user where username = $1 OR email = $1", name) + row := DB.QueryRow("SELECT username, password_hash, active, admin FROM user where username = $1 OR email = $1", name) var db_password []byte + var username string var active bool var isAdmin bool - _ = row.Scan(&db_password, &active, &isAdmin) + _ = row.Scan(&username, &db_password, &active, &isAdmin) if db_password != nil && !active { data := struct { Error string

@@ -246,7 +247,7 @@ }

if bcrypt.CompareHashAndPassword(db_password, []byte(password)) == nil { log.Println("logged in") session, _ := SessionStore.Get(r, "cookie-session") - session.Values["auth_user"] = name + session.Values["auth_user"] = username session.Values["admin"] = isAdmin session.Save(r, w) http.Redirect(w, r, "/my_site", 303)