small changes to error codes and behavior

This commit is contained in:
Pacerino
2022-10-03 22:50:54 +02:00
parent aaef8a4c97
commit 766975f52b
2 changed files with 2 additions and 2 deletions

View File

@@ -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
}
}

View File

@@ -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)