aboutsummaryrefslogtreecommitdiff
path: root/http_handle_login.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 20:26:57 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 20:26:57 +0800
commit20b4fe0c59357a433042732d46e38da9c3d14c3b (patch)
tree537d7d450701a839802b1d57a82bd07324dcba90 /http_handle_login.go
parentmisc: Move utils.go's string function to misc (diff)
downloadforge-20b4fe0c59357a433042732d46e38da9c3d14c3b.tar.gz
forge-20b4fe0c59357a433042732d46e38da9c3d14c3b.tar.zst
forge-20b4fe0c59357a433042732d46e38da9c3d14c3b.zip
database shall no longer be a global variable
Diffstat (limited to 'http_handle_login.go')
-rw-r--r--http_handle_login.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/http_handle_login.go b/http_handle_login.go
index ea1dbae..10bfdcd 100644
--- a/http_handle_login.go
+++ b/http_handle_login.go
@@ -35,7 +35,7 @@ func (s *server) httpHandleLogin(writer http.ResponseWriter, request *http.Reque
username = request.PostFormValue("username")
password = request.PostFormValue("password")
- err = database.QueryRow(request.Context(),
+ err = s.database.QueryRow(request.Context(),
"SELECT id, COALESCE(password, '') FROM users WHERE username = $1",
username,
).Scan(&userID, &passwordHash)
@@ -85,7 +85,7 @@ func (s *server) httpHandleLogin(writer http.ResponseWriter, request *http.Reque
http.SetCookie(writer, &cookie)
- _, err = database.Exec(request.Context(), "INSERT INTO sessions (user_id, session_id) VALUES ($1, $2)", userID, cookieValue)
+ _, err = s.database.Exec(request.Context(), "INSERT INTO sessions (user_id, session_id) VALUES ($1, $2)", userID, cookieValue)
if err != nil {
errorPage500(writer, params, "Error inserting session: "+err.Error())
return