From 61c2fd5412b37749b3a04b1537e837f51b0486c6 Mon Sep 17 00:00:00 2001 From: Chell Date: Sun, 13 Nov 2022 05:16:49 +0100 Subject: [PATCH] feat: fix the issue of jumping back to the login page after resetting password (#1288) * fix: redirect to login page * fix: front end router * fix: front end router * fix: signup page router * fix: redirect to login page --- web/src/Setting.js | 7 +++---- web/src/auth/ForgetPage.js | 5 +++-- web/src/auth/LoginPage.js | 5 +++-- web/src/auth/PromptPage.js | 7 ++++--- web/src/auth/SignupPage.js | 7 ++++--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/web/src/Setting.js b/web/src/Setting.js index 5bbb04c5..a6d0718e 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -13,7 +13,7 @@ // limitations under the License. import React from "react"; -import {Link, useHistory} from "react-router-dom"; +import {Link} from "react-router-dom"; import {Tag, Tooltip, message} from "antd"; import {QuestionCircleTwoTone} from "@ant-design/icons"; import {isMobile as isMobileDevice} from "react-device-detect"; @@ -752,7 +752,7 @@ export function getLoginLink(application) { } else if (authConfig.appName === application.name) { url = "/login"; } else if (application.signinUrl === "") { - url = path.join(application.homepageUrl, "login"); + url = path.join(application.homepageUrl, "/login"); } else { url = application.signinUrl; } @@ -764,9 +764,8 @@ export function renderLoginLink(application, text) { return renderLink(url, text, null); } -export function redirectToLoginPage(application) { +export function redirectToLoginPage(application, history) { const loginLink = getLoginLink(application); - const history = useHistory(); history.push(loginLink); } diff --git a/web/src/auth/ForgetPage.js b/web/src/auth/ForgetPage.js index 82b595da..075f60ca 100644 --- a/web/src/auth/ForgetPage.js +++ b/web/src/auth/ForgetPage.js @@ -23,6 +23,7 @@ import {CountDownInput} from "../common/CountDownInput"; import * as UserBackend from "../backend/UserBackend"; import {CheckCircleOutlined, KeyOutlined, LockOutlined, SolutionOutlined, UserOutlined} from "@ant-design/icons"; import CustomGithubCorner from "../CustomGithubCorner"; +import {withRouter} from "react-router-dom"; const {Step} = Steps; const {Option} = Select; @@ -166,7 +167,7 @@ class ForgetPage extends React.Component { values.userOwner = this.state.application?.organizationObj.name; UserBackend.setPassword(values.userOwner, values.username, "", values?.newPassword).then(res => { if (res.status === "ok") { - Setting.redirectToLoginPage(this.state.application); + Setting.redirectToLoginPage(this.state.application, this.props.history); } else { Setting.showMessage("error", i18next.t(`signup:${res.msg}`)); } @@ -550,4 +551,4 @@ class ForgetPage extends React.Component { } } -export default ForgetPage; +export default withRouter(ForgetPage); diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index 790ed02c..26dae3aa 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -30,6 +30,7 @@ import {CountDownInput} from "../common/CountDownInput"; import SelectLanguageBox from "../SelectLanguageBox"; import {withTranslation} from "react-i18next"; import {CaptchaModal} from "../common/CaptchaModal"; +import {withRouter} from "react-router-dom"; const {TabPane} = Tabs; @@ -339,7 +340,7 @@ class LoginPage extends React.Component { title="Sign Up Error" subTitle={"The application does not allow to sign up new account"} extra={[ -