Skip to content

Commit

Permalink
refactor: 优化 401 状态处理逻辑
Browse files Browse the repository at this point in the history
1.退出接口增加登录校验
2.前端获取用户信息失败,自动清理客户端信息并跳转回登录页
  • Loading branch information
Charles7c committed Nov 7, 2023
1 parent d5da184 commit c70e28a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion continew-admin-ui/src/router/guard/userLoginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function setupUserLoginInfoGuard(router: Router) {
await userStore.getInfo();
next();
} catch (error) {
await userStore.logout();
await userStore.logoutCallBack();
next({
name: 'login',
query: {
Expand Down
2 changes: 1 addition & 1 deletion continew-admin-ui/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ axios.interceptors.response.use(
okText: '重新登录',
async onOk() {
const userStore = useUserStore();
userStore.logout();
userStore.logoutCallBack();
window.location.reload();
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public LoginResp phoneLogin(@Validated @RequestBody PhoneLoginReq loginReq) {
return LoginResp.builder().token(token).build();
}

@SaIgnore
@Operation(summary = "用户退出", description = "注销用户的当前登录")
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
in = ParameterIn.HEADER)
Expand Down

0 comments on commit c70e28a

Please sign in to comment.