Compare commits

...

1 Commits

Author SHA1 Message Date
edd0b30e08 feat: Supports smooth migration of password hash (#3940) 2025-07-11 19:57:55 +08:00

View File

@ -252,7 +252,7 @@ func CheckPassword(user *User, password string, lang string, options ...bool) er
credManager := cred.GetCredManager(passwordType)
if credManager == nil {
return fmt.Errorf(i18n.Translate(lang, "check:unsupported password type: %s"), organization.PasswordType)
return fmt.Errorf(i18n.Translate(lang, "check:unsupported password type: %s"), passwordType)
}
if organization.MasterPassword != "" {
@ -265,6 +265,16 @@ func CheckPassword(user *User, password string, lang string, options ...bool) er
return recordSigninErrorInfo(user, lang, enableCaptcha)
}
isOutdated := passwordType != organization.PasswordType
if isOutdated {
user.Password = password
user.UpdateUserPassword(organization)
_, err = UpdateUser(user.GetId(), user, []string{"password", "password_type", "password_salt"}, true)
if err != nil {
return err
}
}
return resetUserSigninErrorTimes(user)
}