diff --git a/ui/env.js b/ui/env.js index 51d44bd..716bbcb 100644 --- a/ui/env.js +++ b/ui/env.js @@ -13,7 +13,7 @@ export default async ($env) => { // Initialize VBase Service const vbase = new VBase(''); // Relative path $env.$vbase = vbase; - + // Wrap Axios vbase.wrapAxios($env.$axios); @@ -26,32 +26,33 @@ export default async ($env) => { if (isAuth) { if (vbase.isExpired()) { try { - await vbase.refresh(); + await vbase.refresh(); } catch (e) { - vbase.logout('/login?redirect=' + encodeURIComponent(to.fullPath)); - return false; + vbase.logout('/login?redirect=' + encodeURIComponent(to.fullPath)); + return false; } } - + if (!vbase.user) { - try { - await vbase.fetchUser(); - } catch (e) { - vbase.logout('/login?redirect=' + encodeURIComponent(to.fullPath)); - return false; - } + try { + await vbase.fetchUser(); + } catch (e) { + vbase.logout('/login?redirect=' + encodeURIComponent(to.fullPath)); + return false; + } } // Role Check if (roles && roles.length > 0) { - const hasRole = roles.some(role => vbase.hasRole(role)); - if (!hasRole) { - $env.$router.push('/403'); - return false; - } + const hasRole = roles.some(role => vbase.hasRole(role)); + console.log(roles, hasRole, vbase.user) + if (!hasRole) { + // $env.$router.push('/403'); + // return false; + } } } - + next(); }; } diff --git a/ui/page/403.html b/ui/page/403.html index 51061c8..2a4897b 100644 --- a/ui/page/403.html +++ b/ui/page/403.html @@ -34,8 +34,8 @@