[management] reduce calls to update last usage for users and pats (#8290)

This commit is contained in:
Pascal Fischer
2026-10-22 19:13:11 +02:00
committed by GitHub
parent c476196653
commit 431e201355
8 changed files with 178 additions and 27 deletions
+4 -3
View File
@@ -238,9 +238,10 @@ func (am *DefaultAccountManager) GetUserFromUserAuth(ctx context.Context, userAu
// server when user authenticates a device. And we need to separate the Dashboard login event from the Device login event.
newLogin := user.LastDashboardLoginChanged(userAuth.LastLogin)
err = am.Store.SaveUserLastLogin(ctx, userAuth.AccountId, userAuth.UserId, userAuth.LastLogin)
if err != nil {
log.WithContext(ctx).Debugf("failed to update user last login: %v", err)
if userAuth.LastLogin.After(user.GetLastLogin()) {
if err := am.Store.SaveUserLastLogin(ctx, userAuth.AccountId, userAuth.UserId, userAuth.LastLogin); err != nil {
log.WithContext(ctx).Debugf("failed to update user last login: %v", err)
}
}
if newLogin {