Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Forked from erandirjunior/Authoriazation.js
Last active May 2, 2019 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilcorrea/2ad0d8391370e664a17c57cd2732256f to your computer and use it in GitHub Desktop.
Save wilcorrea/2ad0d8391370e664a17c57cd2732256f to your computer and use it in GitHub Desktop.
Busca as permissões caso o usuário recarregue a página
export default ({router, store, Vue}) => {
router.beforeEach((to, from, next) => {
const authorization = to.meta.authorization
if (!authorization) {
next()
return
}
let permissions = store.dispatch('auth/checkPermission')
.then(() => next())
.catch(() => next('/'))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment