You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since angular-meteor-auth 1.1.1, the optional validation function passed to awaitUser is being ignored when the user is already logged-in.
This is due to b7c78da (fixed #25) which introduced a bypass that doesn't use the validation function before resolving :
// If user is already logged in resolve the promise immediately to prevent an
// unnecessary computation
if (this.currentUser) {
deferred.resolve(this.currentUser);
// Keep the schema of the promise consistent
deferred.promise.stop = angular.noop;
return deferred.promise;
}
I already forked the repo and fixed it locally. Let me know if a PR sounds relevant.
The text was updated successfully, but these errors were encountered:
@gsaynac Did you encounter any specific issue because of it? This was done due to optimizations. Unless you have a reason good enough to revert it I wouldn't rush to do it.
We are using this validation function feature all over our app's router and I am pretty sure it is partially broken in version 1.1.1, so that's quite an issue.
// Usage with validation method
$stateProvider
.state({
template: '<my-component></my-component>',
resolve: {
user: ($auth) => {
return $auth.awaitUser((user) => {
if (user.firstName === 'Uri') {
return true;
}
else {
return 'You are not Uri!';
}
}
}
}
});
As mentioned earlier, in case the user is already logged-in, the validation method is not taken into account anymore. This means that $awaitUser's promise will be fulfilled no matter if user.firstName === 'Uri' is true or not. In other words : this example simply won't work.
Concerning the optimisations, I was not talking about reverting it. I actually separated the validation mechanism from the rest of the logic then called it the same way you did in your fix : outside the autorun block if user is already logged-in (to prevent an unnecessary computation, as you said) and inside the autorun block otherwise.
Hello,
Since angular-meteor-auth 1.1.1, the optional validation function passed to awaitUser is being ignored when the user is already logged-in.
This is due to b7c78da (fixed #25) which introduced a bypass that doesn't use the validation function before resolving :
I already forked the repo and fixed it locally. Let me know if a PR sounds relevant.
The text was updated successfully, but these errors were encountered: