diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-10-13 11:13:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-13 03:13:55 +0000 |
commit | 9df5ddaf44aa5a3f319acba7b18645b7b1d4d8a2 (patch) | |
tree | f4dfe4c60ec970725bf247a45367ee7521b87c18 /services/user | |
parent | 6fced335817a23f5a37a601c7f1ebf111821fa32 (diff) | |
download | gitea-9df5ddaf44aa5a3f319acba7b18645b7b1d4d8a2.tar.gz gitea-9df5ddaf44aa5a3f319acba7b18645b7b1d4d8a2.zip |
Only rename a user when they should receive a different name (#32247)
Fix #31996
Diffstat (limited to 'services/user')
-rw-r--r-- | services/user/user.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/services/user/user.go b/services/user/user.go index 2287e36c71..9aded62a51 100644 --- a/services/user/user.go +++ b/services/user/user.go @@ -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{ @@ -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 } |