mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-25 00:44:32 +08:00
feat: 微服务版本 logout接口在配置错误的情况返回401的提示(解决死循环调用logout接口)
This commit is contained in:
@@ -12,6 +12,10 @@ import { notification } from 'ant-design-vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import { doLogout, getUserInfoApi, loginApi, seeConnectionClose } from '#/api';
|
||||
import {
|
||||
ImpossibleReturn401Exception,
|
||||
UnauthorizedException,
|
||||
} from '#/api/helper';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDictStore } from './dict';
|
||||
@@ -83,6 +87,14 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
await Promise.all([seeConnectionClose(), doLogout()]);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
/**
|
||||
* 这两个接口按正常逻辑不可能返回401
|
||||
* 在微服务版本配置错误的情况下 这里会抛出401
|
||||
* 在这里抛出自定义异常供上层处理
|
||||
*/
|
||||
if (error instanceof UnauthorizedException) {
|
||||
throw new ImpossibleReturn401Exception(error.message);
|
||||
}
|
||||
} finally {
|
||||
resetAllStores();
|
||||
accessStore.setLoginExpired(false);
|
||||
|
||||
Reference in New Issue
Block a user