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:
@ -163,7 +163,7 @@ export function getWechatQRCode(providerId) {
|
||||
}
|
||||
|
||||
export function getCaptchaStatus(values) {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-captcha-status?organization=${values["organization"]}&userId=${values["username"]}`, {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-captcha-status?organization=${values["organization"]}&userId=${values["username"]}&application=${values["application"]}`, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
|
@ -134,6 +134,8 @@ class LoginPage extends React.Component {
|
||||
return CaptchaRule.Always;
|
||||
} else if (captchaProviderItems.some(providerItem => providerItem.rule === "Dynamic")) {
|
||||
return CaptchaRule.Dynamic;
|
||||
} else if (captchaProviderItems.some(providerItem => providerItem.rule === "Internet-Only")) {
|
||||
return CaptchaRule.InternetOnly;
|
||||
} else {
|
||||
return CaptchaRule.Never;
|
||||
}
|
||||
@ -443,6 +445,9 @@ class LoginPage extends React.Component {
|
||||
} else if (captchaRule === CaptchaRule.Dynamic) {
|
||||
this.checkCaptchaStatus(values);
|
||||
return;
|
||||
} else if (captchaRule === CaptchaRule.InternetOnly) {
|
||||
this.checkCaptchaStatus(values);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.login(values);
|
||||
@ -961,9 +966,23 @@ class LoginPage extends React.Component {
|
||||
const captchaProviderItems = this.getCaptchaProviderItems(application);
|
||||
const alwaysProviderItems = captchaProviderItems.filter(providerItem => providerItem.rule === "Always");
|
||||
const dynamicProviderItems = captchaProviderItems.filter(providerItem => providerItem.rule === "Dynamic");
|
||||
const provider = alwaysProviderItems.length > 0
|
||||
? alwaysProviderItems[0].provider
|
||||
: dynamicProviderItems[0].provider;
|
||||
const internetOnlyProviderItems = captchaProviderItems.filter(providerItem => providerItem.rule === "Internet-Only");
|
||||
|
||||
// Select provider based on the active captcha rule, not fixed priority
|
||||
const captchaRule = this.getCaptchaRule(this.getApplicationObj());
|
||||
let provider = null;
|
||||
|
||||
if (captchaRule === CaptchaRule.Always && alwaysProviderItems.length > 0) {
|
||||
provider = alwaysProviderItems[0].provider;
|
||||
} else if (captchaRule === CaptchaRule.Dynamic && dynamicProviderItems.length > 0) {
|
||||
provider = dynamicProviderItems[0].provider;
|
||||
} else if (captchaRule === CaptchaRule.InternetOnly && internetOnlyProviderItems.length > 0) {
|
||||
provider = internetOnlyProviderItems[0].provider;
|
||||
}
|
||||
|
||||
if (!provider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <CaptchaModal
|
||||
owner={provider.owner}
|
||||
|
@ -181,4 +181,5 @@ export const CaptchaRule = {
|
||||
Always: "Always",
|
||||
Never: "Never",
|
||||
Dynamic: "Dynamic",
|
||||
InternetOnly: "Internet-Only",
|
||||
};
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Přizpůsobit hlavičku vstupní stránky vaší aplikace",
|
||||
"Incremental": "Inkrementální",
|
||||
"Input": "Vstup",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Kód pozvánky",
|
||||
"Left": "Vlevo",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Links",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Izquierda",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "کد head صفحه ورود برنامه خود را سفارشی کنید",
|
||||
"Incremental": "افزایشی",
|
||||
"Input": "ورودی",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "کد دعوت",
|
||||
"Left": "چپ",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incrémentale",
|
||||
"Input": "Saisie",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Code d'invitation",
|
||||
"Left": "Gauche",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Kiri",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "左",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "왼쪽",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Código de convite",
|
||||
"Left": "Esquerda",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Последовательный",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Код приглашения",
|
||||
"Left": "Левый",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Vlastný HTML kód pre hlavičku vašej vstupnej stránky aplikácie",
|
||||
"Incremental": "Postupný",
|
||||
"Input": "Vstup",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Kód pozvania",
|
||||
"Left": "Vľavo",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Left",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Incremental",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Davet Kodu",
|
||||
"Left": "Sol",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Налаштуйте тег head на сторінці входу до програми",
|
||||
"Incremental": "Інкрементний",
|
||||
"Input": "Введення",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Код запрошення",
|
||||
"Left": "Ліворуч",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "Custom the head tag of your application entry page",
|
||||
"Incremental": "Tăng",
|
||||
"Input": "Input",
|
||||
"Internet-Only": "Internet-Only",
|
||||
"Invalid characters in application name": "Invalid characters in application name",
|
||||
"Invitation code": "Invitation code",
|
||||
"Left": "Trái",
|
||||
|
@ -76,6 +76,7 @@
|
||||
"Header HTML - Tooltip": "自定义应用页面的head标签",
|
||||
"Incremental": "递增",
|
||||
"Input": "输入",
|
||||
"Internet-Only": "外网启用",
|
||||
"Invalid characters in application name": "应用名称内有非法字符",
|
||||
"Invitation code": "邀请码",
|
||||
"Left": "居左",
|
||||
|
@ -255,6 +255,7 @@ class ProviderTable extends React.Component {
|
||||
<Option key="None" value="None">{i18next.t("general:None")}</Option>
|
||||
<Option key="Dynamic" value="Dynamic">{i18next.t("application:Dynamic")}</Option>
|
||||
<Option key="Always" value="Always">{i18next.t("application:Always")}</Option>
|
||||
<Option key="Internet-Only" value="Internet-Only">{i18next.t("application:Internet-Only")}</Option>
|
||||
</Select>
|
||||
);
|
||||
} else if (record.provider?.category === "SMS" || record.provider?.category === "Email") {
|
||||
|
Reference in New Issue
Block a user