Skip to content

Commit 9e9283b

Browse files
lunnyGiteaBot
authored andcommitted
Only rename a user when they should receive a different name (go-gitea#32247)
Fix go-gitea#31996
1 parent f15d5f0 commit 9e9283b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

services/user/user.go

+4-4
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)