From 87db3cf751a6795bb92126b0a56643ea05ea32ba Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 12 Sep 2022 17:34:03 -0400 Subject: [PATCH] better error messages. --- backend/pkg/web/handler/auth.go | 7 ++++--- frontend/src/app/components/footer/footer.component.html | 4 ++-- .../src/app/pages/auth-signin/auth-signin.component.html | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/pkg/web/handler/auth.go b/backend/pkg/web/handler/auth.go index fffb193c..9ceea0a5 100644 --- a/backend/pkg/web/handler/auth.go +++ b/backend/pkg/web/handler/auth.go @@ -1,6 +1,7 @@ package handler import ( + "fmt" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/auth" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" @@ -43,20 +44,20 @@ func AuthSignin(c *gin.Context) { foundUser, err := databaseRepo.GetUserByEmail(c, user.Username) if err != nil || foundUser == nil { - c.JSON(http.StatusInternalServerError, gin.H{"success": false}) + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": fmt.Sprintf("could not find user: %s", user.Username)}) return } err = foundUser.CheckPassword(user.Password) if err != nil { - c.JSON(http.StatusUnauthorized, gin.H{"success": false}) + c.JSON(http.StatusUnauthorized, gin.H{"success": false, "error": fmt.Sprintf("username or password does not match: %s", user.Username)}) return } // return JWT tokenString, err := auth.GenerateJWT(user.Username) if err != nil { - c.JSON(http.StatusInternalServerError, gin.H{"success": false}) + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "an error occurred generating JWT token"}) return } diff --git a/frontend/src/app/components/footer/footer.component.html b/frontend/src/app/components/footer/footer.component.html index 40293519..bf7c8be1 100644 --- a/frontend/src/app/components/footer/footer.component.html +++ b/frontend/src/app/components/footer/footer.component.html @@ -1,8 +1,8 @@ \ No newline at end of file + diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.html b/frontend/src/app/pages/auth-signin/auth-signin.component.html index 8e8f7481..16ad98db 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.html +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.html @@ -36,6 +36,7 @@ +