Closed maxbortone closed 9 years ago
I have the same issue. The problem is in the routeChangeError
event
// some of our routes may reject resolve promises with the special {authRequired: true} error
// this redirects to the login page whenever that is encountered
$rootScope.$on('$routeChangeError', function(e, next, prev, err) {
if( angular.isObject(err) && err.authRequired ) {
$location.path(loginRedirectPath);
}
});
When routeChangeError is triggered, the err
argument is not an object. Actually it is a string with value "AUTH_REQUIRED"
I've swapped ngRoute for ui-router and that issues isn't a problem anymore: the error on $stateChangeError is an object with a property authRequired set to true, if the particular state I'm navigating to is secured in routes.js
. I'm still testing my solution to the issue to see if it is working correctly.
Thanks, gents. Fixed for the 1.0.0 release.
When securing a route using the
whenAuthenticated
method, for example the chat route in the sample app, the redirect isn't triggered immediately after clicking the link in the navigation, while I'm not logged in. However, the redirect works if I go to the chat route using the browser address bar. I was able to solve this problem by replacing the code in my app with the appropriate modules from the angularfire-seed. In particular, I've replacedroutes.js
,simpleLogin.js
and addedchangeEmail.js
.