witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

Reload current route instead of re-sending requests #39

Closed vilmosioo closed 10 years ago

vilmosioo commented 10 years ago

Just curious, why don't you just perform a $route.reload() to redo all the previously unauthorized requests?

PS: Thanks for the great tutorial!

laurelnaiad commented 10 years ago

You're assuming the requests were $ route related.

vilmosioo commented 10 years ago

No. Calling $route.reload() will call all controllers/services/directives involved and it will perform all requests again (which is what you want). Also, $route.reload() does NOT perform a hard refresh in the browser.

cemo commented 10 years ago

Consider a case where user's session is expired at server side. A post request creates a 401 and redirects to login page occurs. In this case after login all requests must be replayed and $route.reload() can not help.

vilmosioo commented 10 years ago

Oh I see, user-generated requests! Brilliant answer, thanks!

witoldsz commented 10 years ago

@stu-salsbury and @cemo are right. More than that, what if I don't use $route at all? Login process does not have to have anything to do with $route service. Oh, and what if application uses $route and $route.reload() will destroy everything user has done on the view, like writing long text? Would you dare to destroy it? :)