update logout logic

This commit is contained in:
AceDataCloud committed 2023-02-12 02:02:25 +08:00
1 parent f22d21bb53
commit 7e23b014b6
4 files changed
+19 -14

No files matched your search

+2 -9
View File
@@ -2,6 +2,7 @@
import { defineComponent } from 'vue';
import { getCookie, removeCookie } from 'typescript-cookie';
import { getAuthBaseUrl, getDataBaseUrl } from '@/utils';
import { removeCookies } from '@/utils/cookie';
interface IData {
accessToken: string | undefined;
@@ -27,15 +28,7 @@ export default defineComponent({
this.$store.dispatch('setAccessToken', this.accessToken);
this.$store.dispatch('setRefreshToken', this.refreshToken);
console.debug('set token successfully');
const host = window.location.host;
// process test env and prod env, for example:
// auth.zhishuyun.com -> .zhishuyun.com
// auth.test.zhishuyun.com -> .zhishuyun.com
const domain = host.replace(/^\S+?\.(test\.)?/, '.');
const path = '/';
// remove tokens from cookies
removeCookie('ACCESS_TOKEN', { domain, path });
removeCookie('REFRESH_TOKEN', { domain, path });
removeCookies();
console.debug('remove cookie for tokens successfully');
// get user info after get access token
this.$store.dispatch('getMe');