flaschengeist-frontend/src/boot/login.ts

21 lines
638 B
TypeScript
Raw Normal View History

2020-10-14 16:44:03 +00:00
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()!
}
})
});