mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
feat: add Internet-Only captcha rule (#3919)
This commit is contained in:
@ -593,7 +593,7 @@ func CheckUpdateUser(oldUser, user *User, lang string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func CheckToEnableCaptcha(application *Application, organization, username string) (bool, error) {
|
||||
func CheckToEnableCaptcha(application *Application, organization, username string, clientIp string) (bool, error) {
|
||||
if len(application.Providers) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
@ -603,6 +603,12 @@ func CheckToEnableCaptcha(application *Application, organization, username strin
|
||||
continue
|
||||
}
|
||||
|
||||
if providerItem.Rule == "Internet-Only" {
|
||||
if util.IsInternetIp(clientIp) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
if providerItem.Rule == "Dynamic" {
|
||||
user, err := GetUserByFields(organization, username)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user