import { boot } from 'quasar/wrappers'; import { UserStateInterface } from 'src/plugins/user/store/user'; import { RouteRecord } from 'vue-router'; export default boot(({ router, store }) => { router.beforeEach((to, from, next) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/ban-ts-comment // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access const user: UserStateInterface = (store.state).user; console.log('login_boot', user); if ( to.matched.some((record: RouteRecord) => { // permissions is set AND has NO matching permission return ( // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access record.meta.permissions !== undefined && !( // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access ( record.meta.permissions.filter((value: string) => user.permissions.includes(value) ).length > 0 ) ) ); }) ) { next({ path: '/login', query: { redirect: to.fullPath } }); } else { next(); } }); });