diff --git a/controllers/auth/loginController.go b/controllers/auth/loginController.go index dfeb37f..062f196 100644 --- a/controllers/auth/loginController.go +++ b/controllers/auth/loginController.go @@ -48,7 +48,7 @@ func LoginController(ctx *fiber.Ctx) error { {"email": body.UsernameOrEmail}, }}).Decode(&userModel) if err != nil { - return ctx.Status(fiber.StatusNotFound).JSON(fiber.Map{ + return ctx.Status(fiber.StatusConflict).JSON(fiber.Map{ "message": "Wrong username or password", }) } @@ -56,7 +56,7 @@ func LoginController(ctx *fiber.Ctx) error { // Check if password is correct argon2id := utils.NewArgon2ID() if ok, err := argon2id.Verify(body.Password, userModel.Password); !ok || err != nil { - return ctx.Status(fiber.StatusNotFound).JSON(fiber.Map{ + return ctx.Status(fiber.StatusConflict).JSON(fiber.Map{ "message": "Wrong username or password", }) } @@ -115,9 +115,8 @@ func LoginController(ctx *fiber.Ctx) error { Name: "refresh_token", Value: refreshToken, Expires: jwt.GetRefreshTokenExpirationTime(), + Secure: false, HTTPOnly: true, - SameSite: "None", - Secure: true, }) // Send response diff --git a/controllers/auth/tokenController.go b/controllers/auth/tokenController.go index c11d266..b656842 100644 --- a/controllers/auth/tokenController.go +++ b/controllers/auth/tokenController.go @@ -11,6 +11,7 @@ import ( func TokenController(ctx *fiber.Ctx) error { refreshToken := ctx.Cookies("refresh_token") + if refreshToken == "" { ctx.Status(fiber.StatusUnauthorized).JSON(fiber.Map{ "message": "Unauthorized", diff --git a/jwt/jwt.go b/jwt/jwt.go index ed57546..ead65d0 100644 --- a/jwt/jwt.go +++ b/jwt/jwt.go @@ -12,7 +12,7 @@ func GetRefreshTokenExpirationTime() time.Time { } func GetAccessTokenExpirationTime() time.Time { - return time.Now().Add(time.Minute * 5) + return time.Now().Add(time.Second * 5) } func GetRefreshTokenSecret(passwordHash string) string {