In my $routeProvider
definition, I included the access
parameter for a route:
$routeProvider.when('/tracks/:trackTitle/:mediaTitle',
{
templateUrl: 'views/track-detail.html',
controller: 'MediaCtrl',
access: access.user
...
}
To ensure user access to the page, I am monitoring the $routeChangeStart
event. If the user does not have access, I save the route in the cookie store and load it after they log in.
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$rootScope.error = null;
if (!Auth.authorize(next.access)) {
if (!Auth.isLoggedIn())
$cookieStore.put('current.user.originalPath', originalPath);
$location.path('/signup');
}});
The issue arises when the next
object seems to change between storing and retrieving it from the cookie store.
Before using $cookieStore.put
, the next
object looks like this:
$$route: Object
params: Object
pathParams: Object
__proto__: Object
However, when I retrieve it with $cookieStore.get
, the object is missing the $$route property:
params: Object
pathParams: Object
__proto__: Object
The question now is why this happens and how can it be resolved?