mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: support reCAPTCHA v3 captcha provider (#3130)
This commit is contained in:
parent
85cbb7d074
commit
a0d6f2125e
@ -24,7 +24,9 @@ func GetCaptchaProvider(captchaType string) CaptchaProvider {
|
||||
switch captchaType {
|
||||
case "Default":
|
||||
return NewDefaultCaptchaProvider()
|
||||
case "reCAPTCHA":
|
||||
case "reCAPTCHA v2":
|
||||
return NewReCaptchaProvider()
|
||||
case "reCAPTCHA v3":
|
||||
return NewReCaptchaProvider()
|
||||
case "Aliyun Captcha":
|
||||
return NewAliyunCaptchaProvider()
|
||||
|
@ -279,7 +279,11 @@ export const OtherProviderInfo = {
|
||||
logo: `${StaticBaseUrl}/img/captcha_default.png`,
|
||||
url: "https://pkg.go.dev/github.com/dchest/captcha",
|
||||
},
|
||||
"reCAPTCHA": {
|
||||
"reCAPTCHA v2": {
|
||||
logo: `${StaticBaseUrl}/img/social_recaptcha.png`,
|
||||
url: "https://www.google.com/recaptcha",
|
||||
},
|
||||
"reCAPTCHA v3": {
|
||||
logo: `${StaticBaseUrl}/img/social_recaptcha.png`,
|
||||
url: "https://www.google.com/recaptcha",
|
||||
},
|
||||
@ -1083,7 +1087,8 @@ export function getProviderTypeOptions(category) {
|
||||
} else if (category === "Captcha") {
|
||||
return ([
|
||||
{id: "Default", name: "Default"},
|
||||
{id: "reCAPTCHA", name: "reCAPTCHA"},
|
||||
{id: "reCAPTCHA v2", name: "reCAPTCHA v2"},
|
||||
{id: "reCAPTCHA v3", name: "reCAPTCHA v3"},
|
||||
{id: "hCaptcha", name: "hCaptcha"},
|
||||
{id: "Aliyun Captcha", name: "Aliyun Captcha"},
|
||||
{id: "GEETEST", name: "GEETEST"},
|
||||
|
@ -27,7 +27,7 @@ export const CaptchaWidget = (props) => {
|
||||
|
||||
useEffect(() => {
|
||||
switch (captchaType) {
|
||||
case "reCAPTCHA": {
|
||||
case "reCAPTCHA v2": {
|
||||
const reTimer = setInterval(() => {
|
||||
if (!window.grecaptcha) {
|
||||
loadScript("https://recaptcha.net/recaptcha/api.js");
|
||||
@ -42,6 +42,20 @@ export const CaptchaWidget = (props) => {
|
||||
}, 300);
|
||||
break;
|
||||
}
|
||||
case "reCAPTCHA v3": {
|
||||
const reTimer = setInterval(() => {
|
||||
if (!window.grecaptcha) {
|
||||
loadScript(`https://recaptcha.net/recaptcha/api.js?render=${siteKey}`);
|
||||
}
|
||||
if (window.grecaptcha && window.grecaptcha.execute) {
|
||||
window.grecaptcha.execute(siteKey, {action: "submit"}).then(function(token) {
|
||||
onChange(token);
|
||||
});
|
||||
clearInterval(reTimer);
|
||||
}
|
||||
}, 300);
|
||||
break;
|
||||
}
|
||||
case "hCaptcha": {
|
||||
const hTimer = setInterval(() => {
|
||||
if (!window.hcaptcha) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user