Skip to content

Commit 5af8483

Browse files
author
Dev Agent
committed
fix: update user login time on login
1 parent 34e72db commit 5af8483

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

user/component/user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,10 @@ func (c *userComponentImpl) Signin(ctx context.Context, code, state string) (*ty
966966
}
967967
// update user login time asynchronously
968968
go func() {
969+
updateCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), time.Second*5)
970+
defer cancel()
969971
dbu.LastLoginAt = time.Now().Format("2006-01-02 15:04:05")
970-
err := c.userStore.Update(ctx, dbu, "")
972+
err := c.userStore.Update(updateCtx, dbu, "")
971973
if err != nil {
972974
slog.ErrorContext(ctx, "failed to update user login time", "error", err, "username", dbu.Username)
973975
}

0 commit comments

Comments
 (0)