refactor: 优化 401 状态处理逻辑
1.退出接口增加登录校验 2.前端获取用户信息失败,自动清理客户端信息并跳转回登录页
This commit is contained in:
parent
d5da1847e3
commit
c70e28a535
@ -23,7 +23,7 @@ export default function setupUserLoginInfoGuard(router: Router) {
|
|||||||
await userStore.getInfo();
|
await userStore.getInfo();
|
||||||
next();
|
next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await userStore.logout();
|
await userStore.logoutCallBack();
|
||||||
next({
|
next({
|
||||||
name: 'login',
|
name: 'login',
|
||||||
query: {
|
query: {
|
||||||
|
@ -60,7 +60,7 @@ axios.interceptors.response.use(
|
|||||||
okText: '重新登录',
|
okText: '重新登录',
|
||||||
async onOk() {
|
async onOk() {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
userStore.logout();
|
userStore.logoutCallBack();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -110,7 +110,6 @@ public class AuthController {
|
|||||||
return LoginResp.builder().token(token).build();
|
return LoginResp.builder().token(token).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SaIgnore
|
|
||||||
@Operation(summary = "用户退出", description = "注销用户的当前登录")
|
@Operation(summary = "用户退出", description = "注销用户的当前登录")
|
||||||
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
|
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
|
||||||
in = ParameterIn.HEADER)
|
in = ParameterIn.HEADER)
|
||||||
|
Loading…
Reference in New Issue
Block a user