witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

My previous implementation was slightly flawed #12

Closed mbrio closed 11 years ago

mbrio commented 11 years ago

I wasn't thinking far enough ahead with ignoring of URLs. Ignoring wasn't the correct way to go, but handling was. The slight difference is that now there are ways to take control of the deferred object during the processing of an ignored URL. An example would be incorrect login credentials triggering the auth-loginRequired event, this would be incorrect instead the application can take control of this process and potentially broadcast a different event like authorization failed. I've also migrated the code to run within a 'use strict' closure and JSLinted.

I've also enabled chaining of the addUrlHandler method.

mbrio commented 11 years ago

You know, to make things easier this round I removed the use strict changes, due to the new tabbing of the script it looked like WAY more was changed than actually was, I'll add some inline comments now. If you look at the diff you'll see that there isn't as much changed as it looked.

mbrio commented 11 years ago

You can see my inline code comments now to see why I chose to make the changes that I made

mbrio commented 11 years ago

I'm going to close this pull request because I've been thinking about my naming scheme for the method handleUrl. I think that maybe I should make this method more more Angular like, I'll work on it this morning and resend the pull later, I'll be switching it to .when(METHOD, URL, function) with helpers for whenGET, whenPOST, whenPUT, whenDELETE. This will mirror how the naming scheme works for url handlers in $httpBackend.