witoldsz / angular-http-auth

MIT License
2.37k stars 416 forks source link

Adapting angular-http-auth to usage in case the 401 is caused by the cached http request #54

Closed alonisser closed 10 years ago

alonisser commented 10 years ago

I bumped into a problem with angular-http-auth (a great lib I enjoyed using and reading the code..) which I managed to solve and was wandering if you would be interested in a PR along those lines:

The problem: We are doing auth with a securitycode/token in params or Authorization header (depending on post or get) , so when I get a 401 from the server, the saved http request includes the wrong param. while the relogin scenario does refresh the security code to an updated one, the buffered http request is retried and creates a 401 once again.

to work around this problem I patched http-auth to receive an object on confirmLogin, that includes the param name to be changed and the new security token, then in retryAll I patch buffer[i].config.params.someparam and buffer[i].config.headers.anotherparam with the new data (if they exists..)

what do you think?

witoldsz commented 10 years ago

What version of angular-http-auth are you using? The feature you are looking for seems to be included for 4 months already (pull req. #36).

alonisser commented 10 years ago

I can see the function in the source code.. (also I don't recall the docs mention it) may work for me, will update

alonisser commented 10 years ago

Thanks work fine! the docs should be more explicit about this. I'll try to get this into a docs PR later.