Closed jbthoma closed 10 years ago
Thanks for pointing this out. Will investigate it in the near future.
For those looking for a quick fix, update the $httpProvider section.
/**
* $http interceptor.
* On 401 response (without 'ignoreAuthModule' option) stores the request
* and broadcasts 'event:angular-auth-loginRequired'.
*/
.config(['$httpProvider', function($httpProvider) {
var interceptor = function($rootScope, $q, httpBuffer) {
return {
'responseError': function(response) {
if (response.status === 401 && !response.config.ignoreAuthModule) {
var deferred = $q.defer();
httpBuffer.append(response.config, deferred);
$rootScope.$broadcast('event:auth-loginRequired');
return deferred.promise;
}
// otherwise, default behaviour
return $q.reject(response);
}
}
};
$httpProvider.interceptors.push(interceptor);
}]);
@cridenour Thanks a lot!
Since AngularJS 1.2.0 is out, can this be merged, please?
+1 for this
Submitted a PR for this.
Merged.
In 1.1.4, $httpProvider.responseInterceptors has been deprecated. The new format ($httpProvider.interceptors) can be seen here: http://code.angularjs.org/1.1.4/docs/api/ng.$http
It would also probably be a good idea to make it resort to the old way if $httpProvider.interceptors doesn't exist, for backwards compatibility.