I'm in the process of configuring vue-router to verify a set of permissions before proceeding with navigation to a new route. These permissions are stored in vuex, and I am looking for a way to avoid passing them as props each time.
Even though I use the next(vm => {})
callback, the navigation proceeds to the next page regardless of the outcome, despite expecting a false
response to stop the navigation.
beforeRouteEnter(to, undefined, next) {
next(vm => {
const allowedRoles = ['Administrator', 'Contributor'];
if (vm.$store.state.authentication.userInfo.userRoles.some(value => allowedRoles.includes(value))) {
return true;
}
else {
return false;
}
});
}
What mistake am I making here that is causing it to fail?