feat: add Internet-Only captcha rule (#3919)

This commit is contained in:
Robin Ye
2025-07-03 02:39:06 +08:00
committed by GitHub
parent 3ccc0339c7
commit bf91ad6c97
34 changed files with 122 additions and 35 deletions

View File

@ -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 {