Skip to content

Commit

Permalink
Merge pull request #131 from witoldsz/prevent_double_event
Browse files Browse the repository at this point in the history
prevent repeating `event:auth-loginRequired` #95 #120 #130
  • Loading branch information
witoldsz committed Mar 24, 2016
2 parents fcc39c6 + 1e26e44 commit 4f14207
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/http-auth-interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
switch (rejection.status) {
case 401:
var deferred = $q.defer();
httpBuffer.append(config, deferred);
$rootScope.$broadcast('event:auth-loginRequired', rejection);
var bufferLength = httpBuffer.append(config, deferred);
if (bufferLength === 1)
$rootScope.$broadcast('event:auth-loginRequired', rejection);
return deferred.promise;
case 403:
$rootScope.$broadcast('event:auth-forbidden', rejection);
Expand Down Expand Up @@ -97,9 +98,10 @@
return {
/**
* Appends HTTP request configuration object with deferred response attached to buffer.
* @return {Number} The new length of the buffer.
*/
append: function(config, deferred) {
buffer.push({
return buffer.push({
config: config,
deferred: deferred
});
Expand Down

0 comments on commit 4f14207

Please sign in to comment.