From 06e078703b5417113a31007a12734e92fed24232 Mon Sep 17 00:00:00 2001 From: Vitaliy Pavlov Date: Thu, 16 May 2024 04:35:44 +0700 Subject: [PATCH] catch set last online error --- auth/auth.go | 10 +++++++++- users/users.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 57b1dce..291aa65 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -50,7 +50,15 @@ func ReqTokens(c *fiber.Ctx) 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) } diff --git a/users/users.go b/users/users.go index fda28d9..ea7865e 100644 --- a/users/users.go +++ b/users/users.go @@ -11,7 +11,7 @@ func Get(c *fiber.Ctx) error { return nil } -func Login(u *entities.User) error { +func SetLoginTime(u *entities.User) error { u.LastLogin = time.Now() return UpdateUser(u, []string{"last_login"}) }