Refactor added saving auth token to redis when successfully logged in
This commit is contained in:
@@ -12,11 +12,15 @@ func (s *Server) LoginHandlerFn(c *fiber.Ctx) error {
|
||||
return s.Error(c, fiber.StatusBadRequest, "Error parsing input")
|
||||
}
|
||||
|
||||
authSrv := service.NewAuthService(s.GetDatabase())
|
||||
authSrv := service.NewAuthService(s.GetDatabase(), s.GetCache())
|
||||
|
||||
token, err := authSrv.Login(data.Username, data.Password)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusUnauthorized)
|
||||
if err == service.ErrUnableToCacheToken {
|
||||
return s.Error(c, fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return s.Error(c, fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(&dto.AuthLoginResponseDTO{Token: token})
|
||||
|
||||
Reference in New Issue
Block a user