Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import store from '../vuex'
- export const beforeEach = (to, from, next) => {
- //next();
- store.dispatch('auth/checkTokenExists').then(() => {
- if(to.meta.guest){
- next({name : 'home'})
- return;
- }
- next();
- }).catch(() => {
- if(to.meta.needAuth){
- next({name : 'login'})
- return;
- }
- next();
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment