Correct handling of the login POST
This commit is contained in:
@@ -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\"}"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user