mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Finish the prompt page logic.
This commit is contained in:
@ -78,6 +78,36 @@ export function isProviderPrompted(providerItem) {
|
||||
return isProviderVisible(providerItem) && providerItem.prompted;
|
||||
}
|
||||
|
||||
export function getAllPromptedProviderItems(application) {
|
||||
return application.providers.filter(providerItem => isProviderPrompted(providerItem));
|
||||
}
|
||||
|
||||
export function getSignupItem(application, itemName) {
|
||||
const signupItems = application.signupItems.filter(signupItem => signupItem.name === itemName);
|
||||
if (signupItems.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return signupItems[0];
|
||||
}
|
||||
|
||||
export function isAffiliationPrompted(application) {
|
||||
const signupItem = getSignupItem(application, "Affiliation");
|
||||
if (signupItem === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return signupItem.prompted;
|
||||
}
|
||||
|
||||
export function hasPromptPage(application) {
|
||||
const providerItems = getAllPromptedProviderItems(application);
|
||||
if (providerItems.length !== 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isAffiliationPrompted(application);
|
||||
}
|
||||
|
||||
export function parseJson(s) {
|
||||
if (s === "") {
|
||||
return null;
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
import React from "react";
|
||||
import {Button, Col, Row} from "antd";
|
||||
import {Link} from "react-router-dom";
|
||||
import {Button, Col, Result, Row} from "antd";
|
||||
import * as ApplicationBackend from "../backend/ApplicationBackend";
|
||||
import * as Setting from "../Setting";
|
||||
import i18next from "i18next";
|
||||
@ -89,21 +90,8 @@ class PromptPage extends React.Component {
|
||||
this.submitUserEdit(false);
|
||||
}
|
||||
|
||||
getAllPromptedProviderItems(application) {
|
||||
return application.providers.filter(providerItem => Setting.isProviderPrompted(providerItem));
|
||||
}
|
||||
|
||||
isAffiliationPrompted(application) {
|
||||
const signupItems = application.signupItems.filter(signupItem => signupItem.name === "Affiliation");
|
||||
if (signupItems.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return signupItems[0].prompted;
|
||||
}
|
||||
|
||||
renderAffiliation(application) {
|
||||
if (!this.isAffiliationPrompted(application)) {
|
||||
if (!Setting.isAffiliationPrompted(application)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -148,7 +136,7 @@ class PromptPage extends React.Component {
|
||||
}
|
||||
|
||||
isAffiliationAnswered(application) {
|
||||
if (!this.isAffiliationPrompted(application)) {
|
||||
if (!Setting.isAffiliationPrompted(application)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -163,7 +151,7 @@ class PromptPage extends React.Component {
|
||||
return false;
|
||||
}
|
||||
|
||||
const providerItems = this.getAllPromptedProviderItems(application);
|
||||
const providerItems = Setting.getAllPromptedProviderItems(application);
|
||||
for (let i = 0; i < providerItems.length; i ++) {
|
||||
if (!this.isProviderItemAnswered(application, providerItems[i])) {
|
||||
return false;
|
||||
@ -201,6 +189,26 @@ class PromptPage extends React.Component {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Setting.hasPromptPage(application)) {
|
||||
return (
|
||||
<Result
|
||||
status="error"
|
||||
title="Sign Up Error"
|
||||
subTitle={"You are unexpected to see this prompt page"}
|
||||
extra={[
|
||||
<Link onClick={() => {
|
||||
Setting.goToLogin(this, application);
|
||||
}}>
|
||||
<Button type="primary" key="signin">
|
||||
Sign In
|
||||
</Button>
|
||||
</Link>
|
||||
]}
|
||||
>
|
||||
</Result>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col span={24} style={{display: "flex", justifyContent: "center"}}>
|
||||
|
@ -97,7 +97,11 @@ class SignupPage extends React.Component {
|
||||
if (authConfig.appName === application.name) {
|
||||
return "/result";
|
||||
} else {
|
||||
return `/result/${application.name}`;
|
||||
if (Setting.hasPromptPage(application)) {
|
||||
return `/prompt/${application.name}`;
|
||||
} else {
|
||||
return `/result/${application.name}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user