I am currently facing a problem in using angular-http-auth library which is handling a state transition from events of event:auth-loginRequired. I am using angular-ui-router for my routing systems.
Anyway here's some pieces of code from the library that emit the events :
case 401:
var deferred = $q.defer();
httpBuffer.append(config, deferred);
$rootScope.$broadcast('event:auth-loginRequired', rejection);
return deferred.promise;
And I was catching the events with these pieces of codes inside myApp.run
$rootScope.$on('event:auth-loginRequired', function(){
console.log('Token Invalid / Expired');
$state.transitionTo('login');
});
I was able to get the 'Token Invalid / Expired' inside my console. However, the state transition didn't work at all and I didn't get any errors on my console too. I've tried using $location.path('/login'), but it doesn't work too.
Can anyone please help me with the solutions? Any kind of help is really appreciated. Thanks!