catch set last online error

This commit is contained in:
Vitaliy Pavlov 2024-05-16 04:35:44 +07:00
parent 37c411f4cb
commit 06e078703b
2 changed files with 10 additions and 2 deletions

View File

@ -50,7 +50,15 @@ func ReqTokens(c *fiber.Ctx) error {
"error": err.Error(), "error": err.Error(),
}) })
} }
users.Login(u)
err = users.SetLoginTime(u)
if err != nil {
return c.
Status(fiber.StatusBadRequest).
JSON(fiber.Map{
"error": err.Error(),
})
}
return c.SendStatus(fiber.StatusOK) return c.SendStatus(fiber.StatusOK)
} }

View File

@ -11,7 +11,7 @@ func Get(c *fiber.Ctx) error {
return nil return nil
} }
func Login(u *entities.User) error { func SetLoginTime(u *entities.User) error {
u.LastLogin = time.Now() u.LastLogin = time.Now()
return UpdateUser(u, []string{"last_login"}) return UpdateUser(u, []string{"last_login"})
} }