Correct handling of the login POST

This commit is contained in:
2024-05-29 14:44:22 +01:00
parent 548ecb756a
commit ccec8affc7
+5
View File
@@ -43,6 +43,8 @@ func Authenticate(w http.ResponseWriter, r *http.Request) {
if !models.ValidateCredentials(&loginForm) {
log.Printf("Invalid credentials.")
w.Header().Set("Content-Type", "text/json")
w.Write([]byte("{\"state\":\"wrong credentials\"}"))
return
}
@@ -75,4 +77,7 @@ func Authenticate(w http.ResponseWriter, r *http.Request) {
}
log.Printf(`| {"user": %s, "time": %d}`, loginForm.Username, time.Now().Unix())
w.Header().Set("Content-Type", "text/json")
w.Write([]byte("{\"state\":\"success\"}"))
}