aboutsummaryrefslogtreecommitdiff
path: root/http_handle_login.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-13 22:58:37 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-13 22:58:37 +0800
commita9d5e405fd9334602c8c74b18558fd0db54a4036 (patch)
treed419865c8663996c46bd407290e834936fc5e78b /http_handle_login.go
parenthttp_handle_*.go: Fix http.Error calls (diff)
downloadforge-a9d5e405fd9334602c8c74b18558fd0db54a4036.tar.gz
forge-a9d5e405fd9334602c8c74b18558fd0db54a4036.tar.zst
forge-a9d5e405fd9334602c8c74b18558fd0db54a4036.zip
http_{server,handle_login}.go: Fix missing error handling
Diffstat (limited to 'http_handle_login.go')
-rw-r--r--http_handle_login.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/http_handle_login.go b/http_handle_login.go
index 2d2dbf6..0785ecc 100644
--- a/http_handle_login.go
+++ b/http_handle_login.go
@@ -57,6 +57,11 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any)
}
cookie_value, err := random_urlsafe_string(16)
+ if err != nil {
+ http.Error(w, "Error getting random string: "+err.Error(), http.StatusInternalServerError)
+ return
+ }
+
now := time.Now()
expiry := now.Add(time.Duration(config.HTTP.CookieExpiry) * time.Second)