witoldsz / angular-http-auth

MIT License
2.38k stars 418 forks source link

Add a configuration option to allow a 403 response buffer request #103

Closed solcre-gr closed 9 years ago

solcre-gr commented 9 years ago

Added a line configuration for the interceptor allows me to set up or not, buffer a request if a response returns me 403, and resend it after the user login. Similarly it happens with the error code 401.

There are servers that return 403 or API, when a token is expired. And it is highly questionable whether to return 401 or 403, so I think the configuration is correct.

So i change this:

case 403:
                $rootScope.$broadcast('event:auth-forbidden', rejection);
                break;
            }

to:

case 403:
                if(rejection.config.authForbiddenBuffer){
                    var deferred = $q.defer();
                    httpBuffer.append(rejection.config, deferred);
                    $rootScope.$broadcast('event:auth-forbidden', rejection);
                    return deferred.promise;
                }
                $rootScope.$broadcast('event:auth-forbidden', rejection);
                break;
            }
witoldsz commented 9 years ago

What is that? A 41 commits long pull request?

solcre-gr commented 9 years ago

Sorry Witold, i do a pull request with wrong commits, you can solve this?

witoldsz commented 9 years ago

I don't think so, it is your pull request. You can try if you can change target branch or if not, discard this and create new one.