From ba2e997d54a1d832c34a7b0e0fec378f128260c7 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Wed, 6 Nov 2024 08:34:13 +0800 Subject: [PATCH] feat: fix CheckUpdateUser() logic to fix add-user error --- object/check.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/object/check.go b/object/check.go index 4bf9eb3d..ac3425d5 100644 --- a/object/check.go +++ b/object/check.go @@ -537,14 +537,19 @@ func CheckUsernameWithEmail(username string, lang string) string { func CheckUpdateUser(oldUser, user *User, lang string) string { if oldUser.Name != user.Name { - // Check if the organization uses email as the username - organization, err := GetOrganizationByUser(oldUser) + organizationName := oldUser.Owner + if organizationName == "" { + organizationName = user.Owner + } + + organization, err := getOrganization("admin", organizationName) if err != nil { return err.Error() } if organization == nil { - return fmt.Sprintf(i18n.Translate(lang, "The organization: %s does not exist"), oldUser.Owner) + return fmt.Sprintf(i18n.Translate(lang, "auth:The organization: %s does not exist"), organizationName) } + if organization.UseEmailAsUsername { if msg := CheckUsernameWithEmail(user.Name, lang); msg != "" { return msg