From 37394fb33604244d68a5ed7657feaad8652e9c19 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 23 Mar 2026 12:53:30 +0100 Subject: [PATCH] fix(user): use getUser directly for uniqueness checks in UpdateUser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pkg/user/user.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/user/user.go b/pkg/user/user.go index 5060b520b..7ca6f5fe0 100644 --- a/pkg/user/user.go +++ b/pkg/user/user.go @@ -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 {