From 39c9fd0a4f5fe70c8c7df73d614abdebac9b47d7 Mon Sep 17 00:00:00 2001 From: Nilo Roberto da Cruz Paim Date: Fri, 11 Aug 2023 08:03:30 -0300 Subject: [PATCH] changed return codes from login endpoint --- controllers/authController.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/controllers/authController.go b/controllers/authController.go index ca90fcd..c40dac1 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -27,11 +27,21 @@ func Login(c *fiber.Ctx) error { database.DB.Where("email = ?", data["email"]).First(&user) if user.Id == 0 { - return fiber.ErrNotFound + return c.JSON(fiber.Map{ + "message": "Usuário não encontrado", + "userId": 0, + "userType": "", + "userName": "", + "token": ""}) } if err := bcrypt.CompareHashAndPassword(user.Password, []byte(data["password"])); err != nil { - return fiber.ErrUnauthorized + return c.JSON(fiber.Map{ + "message": "Senha inválida", + "userId": 0, + "userType": "", + "userName": "", + "token": ""}) } type customClaims struct { @@ -55,6 +65,7 @@ func Login(c *fiber.Ctx) error { } return c.JSON(fiber.Map{ + "message": "", "userId": user.Id, "userType": user.UserType, "userName": user.Name,