mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
feat: fix bug that can not get application in signup/oauth/ router (#1766)
This commit is contained in:
parent
e0028f5eed
commit
4f8dd771bc
@ -25,6 +25,7 @@ import SelfForgetPage from "./auth/SelfForgetPage";
|
|||||||
import ForgetPage from "./auth/ForgetPage";
|
import ForgetPage from "./auth/ForgetPage";
|
||||||
import PromptPage from "./auth/PromptPage";
|
import PromptPage from "./auth/PromptPage";
|
||||||
import CasLogout from "./auth/CasLogout";
|
import CasLogout from "./auth/CasLogout";
|
||||||
|
import {authConfig} from "./auth/Auth";
|
||||||
|
|
||||||
class EntryPage extends React.Component {
|
class EntryPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -71,7 +72,7 @@ class EntryPage extends React.Component {
|
|||||||
<div className="loginBackground" style={{backgroundImage: Setting.inIframe() || Setting.isMobile() ? null : `url(${this.state.application?.formBackgroundUrl})`}}>
|
<div className="loginBackground" style={{backgroundImage: Setting.inIframe() || Setting.isMobile() ? null : `url(${this.state.application?.formBackgroundUrl})`}}>
|
||||||
<Spin size="large" spinning={this.state.application === undefined} tip={i18next.t("login:Loading")} style={{margin: "0 auto"}} />
|
<Spin size="large" spinning={this.state.application === undefined} tip={i18next.t("login:Loading")} style={{margin: "0 auto"}} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...this.props} application={this.state.application} applicationName={authConfig.appName} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
||||||
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
||||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
||||||
<Route exact path="/login/:owner" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
<Route exact path="/login/:owner" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...this.props} application={this.state.application} onUpdateApplication={onUpdateApplication} {...props} />)} />
|
||||||
|
@ -147,7 +147,6 @@ class LoginPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplication() {
|
getApplication() {
|
||||||
@ -600,18 +599,7 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderFooter(application) {
|
renderFooter(application) {
|
||||||
if (this.state.mode === "signup") {
|
|
||||||
return (
|
return (
|
||||||
<div style={{float: "right"}}>
|
|
||||||
{i18next.t("signup:Have account?")}
|
|
||||||
{
|
|
||||||
Setting.renderLoginLink(application, i18next.t("signup:sign in now"))
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<span style={{float: "right"}}>
|
<span style={{float: "right"}}>
|
||||||
{
|
{
|
||||||
!application.enableSignUp ? null : (
|
!application.enableSignUp ? null : (
|
||||||
@ -624,10 +612,8 @@ class LoginPage extends React.Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</React.Fragment>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sendSilentSigninData(data) {
|
sendSilentSigninData(data) {
|
||||||
if (Setting.inIframe()) {
|
if (Setting.inIframe()) {
|
||||||
@ -775,13 +761,9 @@ class LoginPage extends React.Component {
|
|||||||
|
|
||||||
renderMethodChoiceBox() {
|
renderMethodChoiceBox() {
|
||||||
const application = this.getApplicationObj();
|
const application = this.getApplicationObj();
|
||||||
const items = [
|
const items = [];
|
||||||
{label: i18next.t("general:Password"), key: "password"},
|
items.push({label: i18next.t("general:Password"), key: "password"});
|
||||||
];
|
application.enableCodeSignin ? items.push({label: i18next.t("login:Verification code"), key: "verificationCode"}) : null;
|
||||||
application.enableCodeSignin ? items.push({
|
|
||||||
label: i18next.t("login:Verification code"),
|
|
||||||
key: "verificationCode",
|
|
||||||
}) : null;
|
|
||||||
application.enableWebAuthn ? items.push({label: i18next.t("login:WebAuthn"), key: "webAuthn"}) : null;
|
application.enableWebAuthn ? items.push({label: i18next.t("login:WebAuthn"), key: "webAuthn"}) : null;
|
||||||
|
|
||||||
if (application.enableCodeSignin || application.enableWebAuthn) {
|
if (application.enableCodeSignin || application.enableWebAuthn) {
|
||||||
|
@ -66,7 +66,7 @@ class SignupPage extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
applicationName: props.match?.params?.applicationName ?? authConfig.appName,
|
applicationName: props.match?.params?.applicationName ?? null,
|
||||||
email: "",
|
email: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
countryCode: "",
|
countryCode: "",
|
||||||
@ -92,8 +92,11 @@ class SignupPage extends React.Component {
|
|||||||
if (this.getApplicationObj() === undefined) {
|
if (this.getApplicationObj() === undefined) {
|
||||||
if (this.state.applicationName !== null) {
|
if (this.state.applicationName !== null) {
|
||||||
this.getApplication(this.state.applicationName);
|
this.getApplication(this.state.applicationName);
|
||||||
|
} else if (oAuthParams !== null) {
|
||||||
|
this.getApplicationLogin(oAuthParams);
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", `Unknown application name: ${this.state.applicationName}`);
|
Setting.showMessage("error", `Unknown application name: ${this.state.applicationName}`);
|
||||||
|
this.onUpdateApplication(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,6 +112,21 @@ class SignupPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getApplicationLogin(oAuthParams) {
|
||||||
|
AuthBackend.getApplicationLogin(oAuthParams)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.status === "ok") {
|
||||||
|
const application = res.data;
|
||||||
|
this.onUpdateApplication(application);
|
||||||
|
} else {
|
||||||
|
this.onUpdateApplication(null);
|
||||||
|
this.setState({
|
||||||
|
msg: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getResultPath(application) {
|
getResultPath(application) {
|
||||||
if (authConfig.appName === application.name) {
|
if (authConfig.appName === application.name) {
|
||||||
return "/result";
|
return "/result";
|
||||||
@ -178,11 +196,7 @@ class SignupPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isProviderVisible(providerItem) {
|
isProviderVisible(providerItem) {
|
||||||
if (this.state.mode === "signup") {
|
|
||||||
return Setting.isProviderVisibleForSignUp(providerItem);
|
return Setting.isProviderVisibleForSignUp(providerItem);
|
||||||
} else {
|
|
||||||
return Setting.isProviderVisibleForSignIn(providerItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFormItem(application, signupItem) {
|
renderFormItem(application, signupItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user