From 24b65f122ae06f54fbed0f4ae30d9b1ea02b45bf Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 14 Oct 2024 03:27:37 +0800 Subject: [PATCH] Only rename a user when they should receive a different name (#32247) (#32249) Backport #32247 by @lunny Fix #31996 Co-authored-by: Lunny Xiao --- services/user/user.go | 8 ++++---- 1 file 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 }