Skip to content

Commit

Permalink
Refactor user lastlogin update
Browse files Browse the repository at this point in the history
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
  • Loading branch information
bcmmbaga committed Jan 6, 2025
1 parent c8b82b7 commit c29f84f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions management/server/store/sql_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,6 @@ func (s *SqlStore) GetAccountSettings(ctx context.Context, lockStrength LockingS

// SaveUserLastLogin stores the last login time for a user in DB.
func (s *SqlStore) SaveUserLastLogin(ctx context.Context, accountID, userID string, lastLogin time.Time) error {
if lastLogin.IsZero() {
return nil
}

var user types.User
result := s.db.First(&user, accountAndIDQueryCondition, accountID, userID)
if result.Error != nil {
Expand All @@ -898,9 +894,13 @@ func (s *SqlStore) SaveUserLastLogin(ctx context.Context, accountID, userID stri
}
return status.NewGetUserFromStoreError()
}
user.LastLogin = &lastLogin

return s.db.Save(&user).Error
if !lastLogin.IsZero() {
user.LastLogin = &lastLogin
return s.db.Save(&user).Error
}

return nil
}

func (s *SqlStore) GetPostureCheckByChecksDefinition(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) {
Expand Down

0 comments on commit c29f84f

Please sign in to comment.