release v2.0.0 #4
|
@ -8,13 +8,6 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
|
||||||
const session = store.state.session.currentSession;
|
const session = store.state.session.currentSession;
|
||||||
|
|
||||||
if (to.name != 'login') {
|
if (to.name != 'login') {
|
||||||
if (!session || session.expires <= new Date()) {
|
|
||||||
store.dispatch('session/logout').catch(error => {
|
|
||||||
console.warn(error);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
to.matched.every((record: RouteRecord) => {
|
to.matched.every((record: RouteRecord) => {
|
||||||
if (!('meta' in record) || !('permissions' in record.meta))
|
if (!('meta' in record) || !('permissions' in record.meta))
|
||||||
|
@ -30,6 +23,20 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
if (
|
||||||
|
!to.matched.every((record: RouteRecord) => {
|
||||||
|
if (!('meta' in record) || !('permissions' in record.meta))
|
||||||
|
return true;
|
||||||
|
else return false;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
if (!session || session.expires <= new Date()) {
|
||||||
|
store.dispatch('session/logout').catch(error => {
|
||||||
|
console.warn(error);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
next({ name: 'login', query: { redirect: to.fullPath } });
|
next({ name: 'login', query: { redirect: to.fullPath } });
|
||||||
|
|
|
@ -22,17 +22,18 @@ const routes: RouteConfig[] = [
|
||||||
path: '/main',
|
path: '/main',
|
||||||
redirect: 'dashboard',
|
redirect: 'dashboard',
|
||||||
component: () => import('layouts/MainLayout.vue'),
|
component: () => import('layouts/MainLayout.vue'),
|
||||||
|
meta: { permissions: ['user']},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'dashboard',
|
name: 'dashboard',
|
||||||
path: 'dashboard',
|
path: 'dashboard',
|
||||||
meta: { permission: 'user' },
|
meta: { permissions: ['user'] },
|
||||||
component: () => import('pages/Dashboard.vue')
|
component: () => import('pages/Dashboard.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'about',
|
name: 'about',
|
||||||
path: 'about',
|
path: 'about',
|
||||||
meta: { permission: 'user' },
|
meta: { permissions: ['user'] },
|
||||||
component: () => import('pages/about/About.vue')
|
component: () => import('pages/about/About.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue