mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-19 04:43:49 +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)
|
credManager := cred.GetCredManager(passwordType)
|
||||||
if credManager == nil {
|
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 != "" {
|
if organization.MasterPassword != "" {
|
||||||
@ -265,6 +265,16 @@ func CheckPassword(user *User, password string, lang string, options ...bool) er
|
|||||||
return recordSigninErrorInfo(user, lang, enableCaptcha)
|
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)
|
return resetUserSigninErrorTimes(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user