From ccec8affc78c65c259ac79a15cba00ad7e779fd5 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 29 May 2024 14:44:22 +0100 Subject: [PATCH] Correct handling of the login POST --- src/controllers/authentication.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/authentication.go b/src/controllers/authentication.go index d6e133e..4da5d24 100644 --- a/src/controllers/authentication.go +++ b/src/controllers/authentication.go @@ -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\"}")) }