Created
May 3, 2018 06:47
-
-
Save eliran-arkabi/c2ecdb9505884d32ffddc06592ecfd60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default ({ route, store, redirect }) => { | |
| const permissions = [].concat(...route.matched.map((r) => { | |
| return (r.components.default.options ? | |
| r.components.default.options.permissions : | |
| r.components.default.permissions ) | |
| })) | |
| let userAuthorized = true | |
| permissions.forEach((permission) => { | |
| if(typeof permission !== 'undefined' && !store.getters['auth/permissions'].find((p) => p === permission)){ | |
| userAuthorized = false | |
| } | |
| }) | |
| if(!userAuthorized){ | |
| return redirect('/404') | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment