github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/web/src/router/gates.ts (about) 1 import { Store } from 'vuex'; 2 import { NavigationGuard, Location } from 'vue-router'; 3 import { RootState, State } from '@/store'; 4 5 export function authorize(store: Store<RootState>): NavigationGuard { 6 return (to, from, next) => { 7 if (to.meta && to.meta.requiresAuth && !(store.state as State).user.current) { 8 next({ 9 name: 'Login' 10 } as Location); 11 } else { 12 next(); 13 } 14 }; 15 }