release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
3 changed files with 48 additions and 40 deletions
Showing only changes of commit 1ce02a67a9 - Show all commits

View File

@ -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 } });

View File

@ -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')
} }
] ]