mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
feat: improve CheckToEnableCaptcha() logic
This commit is contained in:
@ -599,25 +599,29 @@ func CheckToEnableCaptcha(application *Application, organization, username strin
|
||||
}
|
||||
|
||||
for _, providerItem := range application.Providers {
|
||||
if providerItem.Provider == nil {
|
||||
if providerItem.Provider == nil || providerItem.Provider.Category != "Captcha" {
|
||||
continue
|
||||
}
|
||||
if providerItem.Provider.Category == "Captcha" {
|
||||
if providerItem.Rule == "Dynamic" {
|
||||
user, err := GetUserByFields(organization, username)
|
||||
|
||||
if providerItem.Rule == "Dynamic" {
|
||||
user, err := GetUserByFields(organization, username)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
failedSigninLimit, _, err := GetFailedSigninConfigByUser(user)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
failedSigninLimit := application.FailedSigninLimit
|
||||
if failedSigninLimit == 0 {
|
||||
failedSigninLimit = DefaultFailedSigninLimit
|
||||
}
|
||||
|
||||
return user != nil && user.SigninWrongTimes >= failedSigninLimit, nil
|
||||
return user.SigninWrongTimes >= failedSigninLimit, nil
|
||||
}
|
||||
return providerItem.Rule == "Always", nil
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return providerItem.Rule == "Always", nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
Reference in New Issue
Block a user