From 766975f52ba5c39ba615cb0bf62847b46b1bc311 Mon Sep 17 00:00:00 2001 From: Pacerino Date: Mon, 3 Oct 2022 22:50:54 +0200 Subject: [PATCH] small changes to error codes and behavior --- backend/internal/api/handler/user.go | 2 +- backend/internal/auth/auth.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/internal/api/handler/user.go b/backend/internal/api/handler/user.go index fe82401..8f752ee 100644 --- a/backend/internal/api/handler/user.go +++ b/backend/internal/api/handler/user.go @@ -41,7 +41,7 @@ func (s Handler) UserLogin() func(http.ResponseWriter, *http.Request) { return } else { // if the user was found but there is an error, throw it also - h.ResultErrorJSON(w, r, http.StatusBadGateway, err.Error(), nil) + h.ResultErrorJSON(w, r, http.StatusUnauthorized, err.Error(), nil) return } } diff --git a/backend/internal/auth/auth.go b/backend/internal/auth/auth.go index 15cc905..719e93b 100644 --- a/backend/internal/auth/auth.go +++ b/backend/internal/auth/auth.go @@ -31,7 +31,7 @@ func PeformLogin(email, pass string) (GeneratedResponse, error) { // Compare stored PW and given PW err = bcrypt.CompareHashAndPassword([]byte(user.Secret), []byte(pass)) if err != nil { - return GeneratedResponse{}, errors.New("username or Password is wrong") + return GeneratedResponse{}, errors.New("username or password is wrong") } // Everything seems legit, generate JWT jwtData, err := Generate(&user)