mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Support from link.
This commit is contained in:
@ -441,6 +441,7 @@ class App extends Component {
|
|||||||
|
|
||||||
renderLoginIfNotLoggedIn(component) {
|
renderLoginIfNotLoggedIn(component) {
|
||||||
if (this.state.account === null) {
|
if (this.state.account === null) {
|
||||||
|
sessionStorage.setItem("from", window.location.pathname);
|
||||||
return <Redirect to='/login' />
|
return <Redirect to='/login' />
|
||||||
} else if (this.state.account === undefined) {
|
} else if (this.state.account === undefined) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -638,3 +638,11 @@ export function getRandomName() {
|
|||||||
export function getRandomNumber() {
|
export function getRandomNumber() {
|
||||||
return Math.random().toString(10).slice(-11);
|
return Math.random().toString(10).slice(-11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFromLink() {
|
||||||
|
const from = sessionStorage.getItem("from");
|
||||||
|
if (from === null) {
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
@ -104,7 +104,9 @@ class AuthCallback extends React.Component {
|
|||||||
if (responseType === "login") {
|
if (responseType === "login") {
|
||||||
Util.showMessage("success", `Logged in successfully`);
|
Util.showMessage("success", `Logged in successfully`);
|
||||||
// Setting.goToLinkSoft(this, "/");
|
// Setting.goToLinkSoft(this, "/");
|
||||||
Setting.goToLink("/");
|
|
||||||
|
const link = Setting.getFromLink();
|
||||||
|
Setting.goToLink(link);
|
||||||
} else if (responseType === "code") {
|
} else if (responseType === "code") {
|
||||||
const code = res.data;
|
const code = res.data;
|
||||||
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
|
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
|
||||||
|
@ -124,7 +124,9 @@ class LoginPage extends React.Component {
|
|||||||
const responseType = this.state.type;
|
const responseType = this.state.type;
|
||||||
if (responseType === "login") {
|
if (responseType === "login") {
|
||||||
Util.showMessage("success", `Logged in successfully`);
|
Util.showMessage("success", `Logged in successfully`);
|
||||||
Setting.goToLink("/");
|
|
||||||
|
const link = Setting.getFromLink();
|
||||||
|
Setting.goToLink(link);
|
||||||
} else if (responseType === "code") {
|
} else if (responseType === "code") {
|
||||||
const code = res.data;
|
const code = res.data;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user