21 lines
638 B
TypeScript
21 lines
638 B
TypeScript
|
import { boot } from 'quasar/wrappers';
|
||
|
|
||
|
export default boot(({ Vue, router, store }) => {
|
||
|
router.beforeEach((to, from, next) => {
|
||
|
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||
|
// this route requires auth, check if logged in
|
||
|
// if not, redirect to login page.
|
||
|
if (!store.getters.isLoggedIn()) {
|
||
|
next({
|
||
|
path: '/login',
|
||
|
query: { redirect: to.fullPath }
|
||
|
})
|
||
|
} else {
|
||
|
next()
|
||
|
}
|
||
|
} else {
|
||
|
next() // make sure to always call next()!
|
||
|
}
|
||
|
})
|
||
|
});
|