mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
feat: fix CheckUpdateUser() logic to fix add-user error
This commit is contained in:
@ -537,14 +537,19 @@ func CheckUsernameWithEmail(username string, lang string) string {
|
|||||||
|
|
||||||
func CheckUpdateUser(oldUser, user *User, lang string) string {
|
func CheckUpdateUser(oldUser, user *User, lang string) string {
|
||||||
if oldUser.Name != user.Name {
|
if oldUser.Name != user.Name {
|
||||||
// Check if the organization uses email as the username
|
organizationName := oldUser.Owner
|
||||||
organization, err := GetOrganizationByUser(oldUser)
|
if organizationName == "" {
|
||||||
|
organizationName = user.Owner
|
||||||
|
}
|
||||||
|
|
||||||
|
organization, err := getOrganization("admin", organizationName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
if organization == nil {
|
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 organization.UseEmailAsUsername {
|
||||||
if msg := CheckUsernameWithEmail(user.Name, lang); msg != "" {
|
if msg := CheckUsernameWithEmail(user.Name, lang); msg != "" {
|
||||||
return msg
|
return msg
|
||||||
|
Reference in New Issue
Block a user