Skip to content

Commit 24b65f1

Browse files
GiteaBotlunny
andauthored
Only rename a user when they should receive a different name (#32247) (#32249)
Backport #32247 by @lunny Fix #31996 Co-authored-by: Lunny Xiao <[email protected]>
1 parent bcfe1f9 commit 24b65f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

services/user/user.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ import (
3232

3333
// RenameUser renames a user
3434
func RenameUser(ctx context.Context, u *user_model.User, newUserName string) error {
35+
if newUserName == u.Name {
36+
return nil
37+
}
38+
3539
// Non-local users are not allowed to change their username.
3640
if !u.IsOrganization() && !u.IsLocal() {
3741
return user_model.ErrUserIsNotLocal{
@@ -40,10 +44,6 @@ func RenameUser(ctx context.Context, u *user_model.User, newUserName string) err
4044
}
4145
}
4246

43-
if newUserName == u.Name {
44-
return nil
45-
}
46-
4747
if err := user_model.IsUsableUsername(newUserName); err != nil {
4848
return err
4949
}

0 commit comments

Comments
 (0)