diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-05 08:51:17 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-05 08:51:17 +0800 |
commit | 7c341685f878aa8fd4c49788cf8cc0d8c5c6e127 (patch) | |
tree | 5295f1f4020e85c065e98fcb88ec217ad66e078a /http_auth.go | |
parent | config: Add explanatory comments (diff) | |
download | forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.tar.gz forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.tar.zst forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.zip |
*: Replace some := with var
Diffstat (limited to '')
-rw-r--r-- | http_auth.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/http_auth.go b/http_auth.go index b88fb45..4868aa4 100644 --- a/http_auth.go +++ b/http_auth.go @@ -8,12 +8,17 @@ import ( ) func get_user_info_from_request(r *http.Request) (id int, username string, err error) { - session_cookie, err := r.Cookie("session") - if err != nil { + var session_cookie *http.Cookie + + if session_cookie, err = r.Cookie("session"); err != nil { return } - err = database.QueryRow(r.Context(), "SELECT user_id, COALESCE(username, '') FROM users u JOIN sessions s ON u.id = s.user_id WHERE s.session_id = $1;", session_cookie.Value).Scan(&id, &username) + err = database.QueryRow( + r.Context(), + "SELECT user_id, COALESCE(username, '') FROM users u JOIN sessions s ON u.id = s.user_id WHERE s.session_id = $1;", + session_cookie.Value, + ).Scan(&id, &username) return } |