fix(user): use getUser directly for uniqueness checks in UpdateUser

The username and email uniqueness checks don't need status filtering —
they just need to know if the name/email exists regardless of account
status. Use getUser (which skips the status check) instead of the
public wrappers, reducing cyclomatic complexity back under the threshold.
This commit is contained in:
kolaente 2026-03-23 12:53:30 +01:00 committed by kolaente
parent 8409bdb120
commit 37394fb336
1 changed files with 3 additions and 3 deletions

View File

@ -547,8 +547,8 @@ func UpdateUser(s *xorm.Session, user *User, forceOverride bool) (updatedUser *U
user.Username = theUser.Username // Dont change the username if we dont have one
} else {
// Check if the new username already exists
uu, err := GetUserByUsername(s, user.Username)
if err != nil && !IsErrUserDoesNotExist(err) && !IsErrUserStatusError(err) {
uu, err := getUser(s, &User{Username: user.Username}, false)
if err != nil && !IsErrUserDoesNotExist(err) {
return nil, err
}
if uu.ID != 0 && uu.ID != user.ID {
@ -570,7 +570,7 @@ func UpdateUser(s *xorm.Session, user *User, forceOverride bool) (updatedUser *U
Issuer: user.Issuer,
Subject: user.Subject,
}, true)
if err != nil && !IsErrUserDoesNotExist(err) && !IsErrUserStatusError(err) {
if err != nil && !IsErrUserDoesNotExist(err) {
return nil, err
}
if uu.ID != 0 && uu.ID != user.ID {