Closed thearabbit closed 4 years ago
Vue router does not support tracker reactivity. Yet. See work in progress here: https://github.com/mitar/vue-test
Thanks for your reply. Could we solve or any solution for this?
Yes, it is solvable. But the solution yet has to be made and tested.
BTW, I am not sure that beforeEach
is even reactive even inside Vue itself.
Excuse me, what about vue-meteor-tracker
of Akryum
?
in Akryum
issue
But I don't understand
Now I tries
// Method
export const userIsInRole = new ValidatedMethod({
name: 'userIsInRole',
mixins: [CallPromiseMixin],
validate: new SimpleSchema({
role: {type: String},
}).validator(),
run({role}) {
if (!this.isSimulation) {
return Roles.userIsInRole(Meteor.userId(), role);
}
}
});
---------
// router
router.beforeResolve((to, from, next) => {
// Check user
if (!Meteor.loggingIn() && !Meteor.userId()) {
next({path: '/login'});
} else {
userIsInRole.callPromise({role: to.name}).then((result) => {
if (result) {
next();
} else {
next(false);
alert('no roles');
}
}).catch((err) => {
console.log(err.reason);
});
}
});
It work fine, please advice...
every time show
false
;