0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 19:54:40 +01:00

Only rename a user when they should receive a different name (#32247)

Fix #31996
This commit is contained in:
Lunny Xiao 2024-10-13 11:13:55 +08:00 committed by GitHub
parent 6fced33581
commit 9df5ddaf44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}