refactor: 优化后台登出的逻辑
This commit is contained in:
parent
1969f0dfdf
commit
1e8f2340bd
|
@ -5,8 +5,8 @@ export function login(url, data) {
|
||||||
return post(url, data)
|
return post(url, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logout(sessionId) {
|
export function logout() {
|
||||||
return sessionId ? get("/signout?X-AUTH-TOKEN=" + sessionId) : get("/signout");
|
return get("/signout");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isLogin() {
|
export function isLogin() {
|
||||||
|
|
|
@ -111,19 +111,20 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
userLogout() {
|
userLogout() {
|
||||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
|
||||||
let sessionId = user ? user.sessionId : null;
|
|
||||||
clearSessionStorage();
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
logout(sessionId).then(() => {
|
logout()
|
||||||
location.href = '/#/login';
|
.then(() => {
|
||||||
location.reload();
|
clearSessionStorage();
|
||||||
resolve();
|
location.href = '/#/login';
|
||||||
}).catch(error => {
|
location.reload();
|
||||||
location.href = '/#/login';
|
resolve();
|
||||||
location.reload();
|
})
|
||||||
reject(error);
|
.catch(error => {
|
||||||
})
|
clearSessionStorage();
|
||||||
|
location.href = '/#/login';
|
||||||
|
location.reload();
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
switchWorkspace(response) {
|
switchWorkspace(response) {
|
||||||
|
|
|
@ -95,10 +95,9 @@ public class LoginController {
|
||||||
|
|
||||||
@GetMapping(value = "/signout")
|
@GetMapping(value = "/signout")
|
||||||
@MsAuditLog(module = OperLogModule.AUTH_TITLE, beforeEvent = "#msClass.getUserId(id)", type = OperLogConstants.LOGIN, title = "登出", msClass = SessionUtils.class)
|
@MsAuditLog(module = OperLogModule.AUTH_TITLE, beforeEvent = "#msClass.getUserId(id)", type = OperLogConstants.LOGIN, title = "登出", msClass = SessionUtils.class)
|
||||||
public ResultHolder logout(@RequestParam(name = SessionConstants.HEADER_TOKEN, required = false) String sessionId, HttpServletResponse response) throws Exception {
|
public void logout(HttpServletResponse response) throws Exception {
|
||||||
ssoLogoutService.logout(sessionId, response);
|
ssoLogoutService.logout(SessionUtils.getSessionId(), response);
|
||||||
SecurityUtils.getSubject().logout();
|
SecurityUtils.getSubject().logout();
|
||||||
return ResultHolder.success(StringUtils.EMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Get default language*/
|
/*Get default language*/
|
||||||
|
|
Loading…
Reference in New Issue