mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
Only rename a user when they should receive a different name (#32247)
Fix #31996 (cherry picked from commit 9df5ddaf44aa5a3f319acba7b18645b7b1d4d8a2)
This commit is contained in:
parent
68aa530fb2
commit
8f61fce938
1 changed files with 4 additions and 4 deletions
|
@ -33,6 +33,10 @@ import (
|
||||||
|
|
||||||
// RenameUser renames a user
|
// RenameUser renames a user
|
||||||
func RenameUser(ctx context.Context, u *user_model.User, newUserName string) error {
|
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.
|
// Non-local users are not allowed to change their username.
|
||||||
if !u.IsOrganization() && !u.IsLocal() {
|
if !u.IsOrganization() && !u.IsLocal() {
|
||||||
return user_model.ErrUserIsNotLocal{
|
return user_model.ErrUserIsNotLocal{
|
||||||
|
@ -41,10 +45,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 {
|
if err := user_model.IsUsableUsername(newUserName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue