witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

Modify request headers before httpBuffer.retryAll() #24

Closed airtonix closed 11 years ago

airtonix commented 11 years ago

https://github.com/witoldsz/angular-http-auth/blob/master/src/http-auth-interceptor.js#L23

After login and before replay of all buffered requests, I need to modify the headers so that they include a required Authorization header with username and apikey.

I'm new to angular, but would it be good enough to do something like : https://github.com/edmenendez/django-angular-auth/blob/master/static/js/controllers.js#L27

airtonix commented 11 years ago

The solution is to use the $http.post, $http.get, $http.put, $http.patch, $http.delete, shortcuts instead of $http({ method: "POST"}).

This way they use the common headers which you can update at anytime,

laurelnaiad commented 11 years ago

What, if anything, needs to happen such that buffered $http requests are retried with either the up-to-date default configuration, or with an override that is specific to the retries?

Right now it looks like the config is bundled in the retry buffer... would it be correct/useful to take what's in the retry buffer, merge the new $http defaults onto it, and then merge anything provided by the loginConfirmed function as an extra level of controlling those requests?

So, the default behavior would be:

I think I should have written code to express that...

Basically, make sure that by default http-auth takes the combination of the fresh default $http config when it retries.

And for bonus points, let someone specify additional overrides to the defaults for purposes of only the retries.