diff options
Diffstat (limited to 'handlers.go')
| -rw-r--r-- | handlers.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/handlers.go b/handlers.go index ceeb79a..0ff2f26 100644 --- a/handlers.go +++ b/handlers.go @@ -45,7 +45,7 @@ func ApiAuthentication(db *sql.DB) http.Handler { err := dec.Decode(&data) if err != nil { - log.Printf("Failed to decode: %v", err) + log.Printf("Failed to decode: %v.", err) w.WriteHeader(http.StatusBadRequest) return } @@ -61,5 +61,12 @@ func ApiAuthentication(db *sql.DB) http.Handler { w.WriteHeader(http.StatusBadRequest) return } + + err = Authenticate(db, data.Username, data.Password) + if err != nil { + log.Printf("Bad password on authentication of user '%s'.", data.Username) + w.WriteHeader(http.StatusUnauthorized) + return + } }) } |
