mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
feat: fix CAS logout failure caused by Beego session update problem (#3194)
* feat: fix the cas logout failure caused by beego session update problem * fix: simplify the implementation of logout timer * fix: change the location of the login success code * fix: add i18n to CasLogout.js
This commit is contained in:
@ -34,13 +34,22 @@ class CasLogout extends React.Component {
|
|||||||
|
|
||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
const params = new URLSearchParams(this.props.location.search);
|
const params = new URLSearchParams(this.props.location.search);
|
||||||
|
const logoutInterval = 100;
|
||||||
|
|
||||||
AuthBackend.logout()
|
const logoutTimeOut = (redirectUri) => {
|
||||||
.then((res) => {
|
setTimeout(() => {
|
||||||
if (res.status === "ok") {
|
AuthBackend.getAccount().then((accountRes) => {
|
||||||
Setting.showMessage("success", "Logged out successfully");
|
if (accountRes.status === "ok") {
|
||||||
|
AuthBackend.logout().then((logoutRes) => {
|
||||||
|
if (logoutRes.status === "ok") {
|
||||||
|
logoutTimeOut(logoutRes.data2);
|
||||||
|
} else {
|
||||||
|
Setting.showMessage("error", `${i18next.t("login:Failed to log out")}: ${logoutRes.msg}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Setting.showMessage("success", i18next.t("application:Logged out successfully"));
|
||||||
this.props.onUpdateAccount(null);
|
this.props.onUpdateAccount(null);
|
||||||
const redirectUri = res.data2;
|
|
||||||
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
||||||
Setting.goToLink(redirectUri);
|
Setting.goToLink(redirectUri);
|
||||||
} else if (params.has("service")) {
|
} else if (params.has("service")) {
|
||||||
@ -48,11 +57,19 @@ class CasLogout extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
Setting.goToLinkSoft(this, `/cas/${this.state.owner}/${this.state.applicationName}/login`);
|
Setting.goToLinkSoft(this, `/cas/${this.state.owner}/${this.state.applicationName}/login`);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Setting.showMessage("error", `Failed to log out: ${res.msg}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, logoutInterval);
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthBackend.logout()
|
||||||
|
.then((res) => {
|
||||||
|
if (res.status === "ok") {
|
||||||
|
logoutTimeOut(res.data2);
|
||||||
|
} else {
|
||||||
|
Setting.showMessage("error", `${i18next.t("login:Failed to log out")}: ${res.msg}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Reference in New Issue
Block a user