Skip to content

Commit

Permalink
Only rename a user when they should receive a different name (go-gite…
Browse files Browse the repository at this point in the history
…a#32247) (go-gitea#32249)

Backport go-gitea#32247 by @lunny

Fix go-gitea#31996

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
  • Loading branch information
GiteaBot and lunny authored Oct 13, 2024
1 parent bcfe1f9 commit 24b65f1
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 24b65f1

Please sign in to comment.