mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
feat: use React routing to remove spin between signup and signin pages (#2740)
* fix: Regarding the color of loading * fix: use goToLinkSoft and use same code format with result and forget psw * fix: update signup url
This commit is contained in:
@ -1165,7 +1165,7 @@ export function getLoginLink(application) {
|
|||||||
if (application === null) {
|
if (application === null) {
|
||||||
url = null;
|
url = null;
|
||||||
} else if (window.location.pathname.includes("/signup/oauth/authorize")) {
|
} else if (window.location.pathname.includes("/signup/oauth/authorize")) {
|
||||||
url = window.location.href.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
url = window.location.pathname.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||||
} else if (authConfig.appName === application.name) {
|
} else if (authConfig.appName === application.name) {
|
||||||
url = "/login";
|
url = "/login";
|
||||||
} else if (application.signinUrl === "") {
|
} else if (application.signinUrl === "") {
|
||||||
@ -1173,7 +1173,7 @@ export function getLoginLink(application) {
|
|||||||
} else {
|
} else {
|
||||||
url = application.signinUrl;
|
url = application.signinUrl;
|
||||||
}
|
}
|
||||||
return url;
|
return url + window.location.search;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function redirectToLoginPage(application, history) {
|
export function redirectToLoginPage(application, history) {
|
||||||
@ -1216,7 +1216,7 @@ export function renderSignupLink(application, text) {
|
|||||||
if (application === null) {
|
if (application === null) {
|
||||||
url = null;
|
url = null;
|
||||||
} else if (window.location.pathname.includes("/login/oauth/authorize")) {
|
} else if (window.location.pathname.includes("/login/oauth/authorize")) {
|
||||||
url = window.location.href.replace("/login/oauth/authorize", "/signup/oauth/authorize");
|
url = window.location.pathname.replace("/login/oauth/authorize", "/signup/oauth/authorize");
|
||||||
} else if (authConfig.appName === application.name) {
|
} else if (authConfig.appName === application.name) {
|
||||||
url = "/signup";
|
url = "/signup";
|
||||||
} else {
|
} else {
|
||||||
@ -1228,10 +1228,10 @@ export function renderSignupLink(application, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const storeSigninUrl = () => {
|
const storeSigninUrl = () => {
|
||||||
sessionStorage.setItem("signinUrl", window.location.href);
|
sessionStorage.setItem("signinUrl", window.location.pathname + window.location.search);
|
||||||
};
|
};
|
||||||
|
|
||||||
return renderLink(url, text, storeSigninUrl);
|
return renderLink(url + window.location.search, text, storeSigninUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderForgetLink(application, text) {
|
export function renderForgetLink(application, text) {
|
||||||
@ -1249,7 +1249,7 @@ export function renderForgetLink(application, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const storeSigninUrl = () => {
|
const storeSigninUrl = () => {
|
||||||
sessionStorage.setItem("signinUrl", window.location.href);
|
sessionStorage.setItem("signinUrl", window.location.pathname + window.location.search);
|
||||||
};
|
};
|
||||||
|
|
||||||
return renderLink(url, text, storeSigninUrl);
|
return renderLink(url, text, storeSigninUrl);
|
||||||
|
@ -156,7 +156,7 @@ class ForgetPage extends React.Component {
|
|||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||||
if (linkInStorage !== null && linkInStorage !== "") {
|
if (linkInStorage !== null && linkInStorage !== "") {
|
||||||
Setting.goToLink(linkInStorage);
|
Setting.goToLinkSoft(linkInStorage);
|
||||||
} else {
|
} else {
|
||||||
Setting.redirectToLoginPage(this.getApplicationObj(), this.props.history);
|
Setting.redirectToLoginPage(this.getApplicationObj(), this.props.history);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class ResultPage extends React.Component {
|
|||||||
<Button type="primary" key="login" onClick={() => {
|
<Button type="primary" key="login" onClick={() => {
|
||||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||||
if (linkInStorage !== null && linkInStorage !== "") {
|
if (linkInStorage !== null && linkInStorage !== "") {
|
||||||
Setting.goToLink(linkInStorage);
|
Setting.goToLinkSoft(this, linkInStorage);
|
||||||
} else {
|
} else {
|
||||||
Setting.redirectToLoginPage(application, this.props.history);
|
Setting.redirectToLoginPage(application, this.props.history);
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ class SignupPage extends React.Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const oAuthParams = Util.getOAuthGetParameters();
|
const oAuthParams = Util.getOAuthGetParameters();
|
||||||
if (oAuthParams !== null) {
|
if (oAuthParams !== null) {
|
||||||
const signinUrl = window.location.href.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
const signinUrl = window.location.pathname.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||||
sessionStorage.setItem("signinUrl", signinUrl);
|
sessionStorage.setItem("signinUrl", signinUrl + window.location.search);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getApplicationObj() === undefined) {
|
if (this.getApplicationObj() === undefined) {
|
||||||
@ -639,7 +639,7 @@ class SignupPage extends React.Component {
|
|||||||
<a onClick={() => {
|
<a onClick={() => {
|
||||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||||
if (linkInStorage !== null && linkInStorage !== "") {
|
if (linkInStorage !== null && linkInStorage !== "") {
|
||||||
Setting.goToLink(linkInStorage);
|
Setting.goToLinkSoft(this, linkInStorage);
|
||||||
} else {
|
} else {
|
||||||
Setting.redirectToLoginPage(application, this.props.history);
|
Setting.redirectToLoginPage(application, this.props.history);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user