aboutsummaryrefslogtreecommitdiff
path: root/http_handle_login.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-13 19:05:22 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-13 19:05:22 +0800
commitd7889bf3eab55f56d2ca94c462ca130fde705871 (patch)
treeaeecbbc43bb8608ef2299fa167da4d00bf53f98d /http_handle_login.go
parentschema.sql: password TEXT should not be NOT NULL (diff)
downloadforge-d7889bf3eab55f56d2ca94c462ca130fde705871.tar.gz
forge-d7889bf3eab55f56d2ca94c462ca130fde705871.tar.zst
forge-d7889bf3eab55f56d2ca94c462ca130fde705871.zip
http_handle_*.go: Fix http.Error calls
Previously when I was converting the fmt.Fprintln calls into http.Error, there was a mistake in my sed command which caused some of the messages to have double colons. This should fix them.
Diffstat (limited to 'http_handle_login.go')
-rw-r--r--http_handle_login.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/http_handle_login.go b/http_handle_login.go
index 70a8c8b..2d2dbf6 100644
--- a/http_handle_login.go
+++ b/http_handle_login.go
@@ -16,7 +16,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any)
if r.Method != "POST" {
err := templates.ExecuteTemplate(w, "login", params)
if err != nil {
- http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError)
}
return
}
@@ -32,17 +32,17 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any)
params["login_error"] = "Unknown username"
err := templates.ExecuteTemplate(w, "login", params)
if err != nil {
- http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError)
}
return
}
- http.Error(w, "Error querying user information:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error querying user information: "+err.Error(), http.StatusInternalServerError)
return
}
match, err := argon2id.ComparePasswordAndHash(password, password_hash)
if err != nil {
- http.Error(w, "Error comparing password and hash:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error comparing password and hash: "+err.Error(), http.StatusInternalServerError)
return
}
@@ -50,7 +50,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any)
params["login_error"] = "Invalid password"
err := templates.ExecuteTemplate(w, "login", params)
if err != nil {
- http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError)
return
}
return
@@ -75,7 +75,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any)
_, err = database.Exec(r.Context(), "INSERT INTO sessions (user_id, session_id) VALUES ($1, $2)", user_id, cookie_value)
if err != nil {
- http.Error(w, "Error inserting session:: "+err.Error(), http.StatusInternalServerError)
+ http.Error(w, "Error inserting session: "+err.Error(), http.StatusInternalServerError)
return
}