mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-16 10:43:35 +08:00
feat: Supports smooth migration of password hash (#3940)
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user