feat: fix bug that can not get application in signup/oauth/ router (#1766)

This commit is contained in:
Yaodong Yu
2023-04-22 18:20:45 +08:00
committed by GitHub
parent e0028f5eed
commit 4f8dd771bc
3 changed files with 39 additions and 42 deletions

View File

@ -66,7 +66,7 @@ class SignupPage extends React.Component {
super(props);
this.state = {
classes: props,
applicationName: props.match?.params?.applicationName ?? authConfig.appName,
applicationName: props.match?.params?.applicationName ?? null,
email: "",
phone: "",
countryCode: "",
@ -92,8 +92,11 @@ class SignupPage extends React.Component {
if (this.getApplicationObj() === undefined) {
if (this.state.applicationName !== null) {
this.getApplication(this.state.applicationName);
} else if (oAuthParams !== null) {
this.getApplicationLogin(oAuthParams);
} else {
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) {
if (authConfig.appName === application.name) {
return "/result";
@ -178,11 +196,7 @@ class SignupPage extends React.Component {
}
isProviderVisible(providerItem) {
if (this.state.mode === "signup") {
return Setting.isProviderVisibleForSignUp(providerItem);
} else {
return Setting.isProviderVisibleForSignIn(providerItem);
}
return Setting.isProviderVisibleForSignUp(providerItem);
}
renderFormItem(application, signupItem) {