Browse Source

Update router-guards.ts

lex 1 year ago
parent
commit
4aaad7ede5
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/router/router-guards.ts

+ 6 - 2
src/router/router-guards.ts

@@ -2,7 +2,7 @@ import { isNavigationFailure, Router } from 'vue-router';
 import { useUserStore } from '@/store/modules/users';
 import { storage } from '@/utils/storage';
 import { PageEnum } from '@/enums/pageEnum';
-import { ACCESS_TOKEN } from '@/store/mutation-types';
+import { ACCESS_TOKEN, ACCESS_TOKEN_ADMIN } from '@/store/mutation-types';
 
 const LOGIN_PATH = PageEnum.BASE_LOGIN;
 
@@ -63,7 +63,11 @@ export function createRouterGuards(router: Router) {
       return;
     }
 
-    const token = storage.get(ACCESS_TOKEN);
+    let token = storage.get(ACCESS_TOKEN);
+    const authSource = sessionStorage.getItem('authSource');
+    if (authSource === 'admin' && storage.get(ACCESS_TOKEN_ADMIN)) {
+      token = storage.get(ACCESS_TOKEN_ADMIN);
+    }
     // console.log(token, 'access token');
     if (!token) {
       // You can access without permissions. You need to set the routing meta.ignoreAuth to true