flounder

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

commit 77676e3b079aad7ed0d722533341e3dba562034a
parent dd52cd247d7bc0f86bbb64c9fa33f4355d6f9b7b
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 31 Oct 2020 00:01:59 -0700

Fix bug with email login

Diffstat:
Mhttp.go | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

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