flounder

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

commit 729f3dd39dab2712dfb264dd67fb8b4aa1d7605a
parent d2a93d9ebce46334ed7b05fc8d5691c70094de9f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu, 14 Jan 2021 20:41:54 -0800

Better error handling on nonexistent user

Diffstat:
Mhttp.go | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/http.go b/http.go @@ -379,7 +379,16 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { var isAdmin bool err := row.Scan(&username, &db_password, &active, &isAdmin) if err != nil { - panic(err) + if strings.Contains(err.Error(), "no rows") { + data := struct { + Error string + Config Config + }{"Username or email '" + name + "' does not exist", c} + t.ExecuteTemplate(w, "login.html", data) + return + } else { + panic(err) + } } if db_password != nil && !active { data := struct {