Skip to content

Commit

Permalink
Only rename a user when they should receive a different name (#32247)
Browse files Browse the repository at this point in the history
Fix #31996
  • Loading branch information
lunny authored Oct 13, 2024
1 parent 6fced33 commit 9df5dda
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions services/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (

// RenameUser renames a user
func RenameUser(ctx context.Context, u *user_model.User, newUserName string) error {
if newUserName == u.Name {
return nil
}

// Non-local users are not allowed to change their username.
if !u.IsOrganization() && !u.IsLocal() {
return user_model.ErrUserIsNotLocal{
Expand All @@ -40,10 +44,6 @@ func RenameUser(ctx context.Context, u *user_model.User, newUserName string) err
}
}

if newUserName == u.Name {
return nil
}

if err := user_model.IsUsableUsername(newUserName); err != nil {
return err
}
Expand Down

0 comments on commit 9df5dda

Please sign in to comment.