2020-10-14 16:44:03 +00:00
|
|
|
import { boot } from 'quasar/wrappers';
|
2020-10-15 01:36:25 +00:00
|
|
|
import { StateInterface } from '../store';
|
2020-10-14 16:44:03 +00:00
|
|
|
|
|
|
|
export default boot(({ Vue, router, store }) => {
|
2020-10-16 07:38:14 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
let user = (<StateInterface>store.state).user;
|
|
|
|
console.log('login_boot', user);
|
|
|
|
if (
|
|
|
|
to.matched.some(record => {
|
|
|
|
// permissions is set AND has NO matching permission
|
|
|
|
return (
|
|
|
|
record.meta.permissions !== undefined &&
|
|
|
|
!(
|
|
|
|
record.meta.permissions.filter((value: string) =>
|
|
|
|
user.permissions.includes(value)
|
|
|
|
).length > 0
|
|
|
|
)
|
|
|
|
);
|
|
|
|
})
|
|
|
|
) {
|
|
|
|
next({
|
|
|
|
path: '/login',
|
|
|
|
query: { redirect: to.fullPath }
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
});
|
2020-10-14 16:44:03 +00:00
|
|
|
});
|