From a58df645bf64abcd528f70980a2f52b72fa9b316 Mon Sep 17 00:00:00 2001 From: Yaodong Yu <2814461814@qq.com> Date: Sat, 8 Jul 2023 22:35:31 +0800 Subject: [PATCH] fix: fix state after mfa is enabled (#2050) --- web/src/App.js | 7 ++----- web/src/EntryPage.js | 2 +- web/src/auth/MfaSetupPage.js | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/web/src/App.js b/web/src/App.js index a41311c8..07a0d83f 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -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 { this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> - this.renderLoginIfNotLoggedIn( this.setState({requiredEnableMfa: result})} {...props} />)} /> + this.renderLoginIfNotLoggedIn( this.setState({requiredEnableMfa: false})} {...props} />)} /> } /> this.renderLoginIfNotLoggedIn()} /> ; + return ; } else { return component; } diff --git a/web/src/auth/MfaSetupPage.js b/web/src/auth/MfaSetupPage.js index 7bbb61b7..89b2d02a 100644 --- a/web/src/auth/MfaSetupPage.js +++ b/web/src/auth/MfaSetupPage.js @@ -190,7 +190,7 @@ class MfaSetupPage extends React.Component { { 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");