Closed
Description
To check whether the user is authorized for a certain state, i implemented an interceptor which listens to the $stateChangeStart event. After checking the rights, I resume the transition with the following code:
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
//Auth stuff checking here
$state.go(toState, toParams, {notify: false}).then(() => {
$rootScope.$broadcast('$stateChangeSuccess', toState, toParams, fromState, fromParams);
});
});
I notify the stateChangeSucces by hand to prevent endless loops here. The problem is that state.go calls which provides optional options (like reload:true) are not provided by the $stateChangeStart event. This prevents resuming the started transition correctly (because the provided options as originally passed to the state.go method are lost).
Alternative would be to provide a method like $state.resume() which can be used to resume a prevented state transition which takes into account the passed params and options.