witoldsz / angular-http-auth

MIT License
2.38k stars 418 forks source link

How angular-http-auth-buffer works ? #125

Closed toben closed 8 years ago

toben commented 8 years ago

Hi,

I am using the module http-auth-buffer. For my test, I give for the user a token which expires in 10 seconds. When I log in, my user goes on a page which does 5 requests to my web api. I wait 10 seconds, then I refresh the page. The buffer works because it calls only once my api.com/Token and then it calls my 5 requests.. But, the buffer doesn't work when I don't refresh but go on an other view. In this case, it calls 3 api.com/Token so the first one works, but the others fail because the first one change the refresh_token...

witoldsz commented 8 years ago

Hi, I am sorry, I can't help you much in this very case. It would be best if you could look here: src.js line 27 and here: src.js line 37. This is the place that propagates the buffer: src.js line 59 The source code of that buffer is here: src.js line 77

I hope that helps!

witoldsz commented 8 years ago

One more thing, check out that updater argument passed to the buffer on login confirmed. It allows you to inject a transformation function to the buffered requests just before retrying the requests (like maybe changing the tokens in your case?)