mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
fix: fix state after mfa is enabled (#2050)
This commit is contained in:
@ -130,10 +130,8 @@ class App extends Component {
|
||||
this.setState({
|
||||
requiredEnableMfa: requiredEnableMfa,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.state.requiredEnableMfa !== prevState.requiredEnableMfa || this.state.account !== prevState.account) {
|
||||
if (this.state.requiredEnableMfa === true) {
|
||||
if (requiredEnableMfa === true) {
|
||||
const mfaType = Setting.getMfaItemsByRules(this.state.account, this.state.account?.organization, [MfaRuleRequired])
|
||||
.find((item) => item.rule === MfaRuleRequired)?.name;
|
||||
if (mfaType !== undefined) {
|
||||
@ -144,7 +142,6 @@ class App extends Component {
|
||||
}
|
||||
|
||||
updateMenuKey() {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
const uri = location.pathname;
|
||||
this.setState({
|
||||
uri: uri,
|
||||
@ -636,7 +633,7 @@ class App extends Component {
|
||||
<Route exact path="/payments/:paymentName" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentEditPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/payments/:paymentName/result" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentResultPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/records" render={(props) => this.renderLoginIfNotLoggedIn(<RecordListPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/mfa/setup" render={(props) => this.renderLoginIfNotLoggedIn(<MfaSetupPage account={this.state.account} onfinish={result => this.setState({requiredEnableMfa: result})} {...props} />)} />
|
||||
<Route exact path="/mfa/setup" render={(props) => this.renderLoginIfNotLoggedIn(<MfaSetupPage account={this.state.account} onfinish={() => this.setState({requiredEnableMfa: false})} {...props} />)} />
|
||||
<Route exact path="/.well-known/openid-configuration" render={(props) => <OdicDiscoveryPage />} />
|
||||
<Route exact path="/sysinfo" render={(props) => this.renderLoginIfNotLoggedIn(<SystemInfo account={this.state.account} {...props} />)} />
|
||||
<Route path="" render={() => <Result status="404" title="404 NOT FOUND" subTitle={i18next.t("general:Sorry, the page you visited does not exist.")}
|
||||
|
@ -41,7 +41,7 @@ class EntryPage extends React.Component {
|
||||
|
||||
renderHomeIfLoggedIn(component) {
|
||||
if (this.props.account !== null && this.props.account !== undefined) {
|
||||
return <Redirect to="/" />;
|
||||
return <Redirect to={{pathname: "/", state: {from: "/login"}}} />;
|
||||
} else {
|
||||
return component;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ class MfaSetupPage extends React.Component {
|
||||
<MfaEnableForm user={this.getUser()} mfaType={this.state.mfaType} recoveryCodes={this.state.mfaProps.recoveryCodes}
|
||||
onSuccess={() => {
|
||||
Setting.showMessage("success", i18next.t("general:Enabled successfully"));
|
||||
this.props.onfinish(true);
|
||||
this.props.onfinish();
|
||||
if (localStorage.getItem("mfaRedirectUrl") !== null) {
|
||||
Setting.goToLink(localStorage.getItem("mfaRedirectUrl"));
|
||||
localStorage.removeItem("mfaRedirectUrl");
|
||||
|
Reference in New Issue
Block a user