JamesRandall / AngularJS-OAuth2

Package for allowing an AngularJS application to authenticate with an OAuth 2 / Open ID Connect identity provider using the implicit flow.
MIT License
46 stars 42 forks source link

Reject response on error #24

Closed vvmoppescapita closed 8 years ago

vvmoppescapita commented 8 years ago

The correct way to close a response error handler is to reject the response, not simply return it, or anything using the plugin won't be able to use the error handler clause with their promises.

vvmoppescapita commented 8 years ago

Just to be clear, the interceptor overrides the behaviour for everything in the project that includes the oauth plugin. This causes some unexpected behaviour, for example where I'm returning error 400 (bad request) from my webapi backend. Instead of angular passing on the error to my error handler (of my .then call) it comes back as a "successful" response, with the error details in the response as if it was the data I requested.

vothlizard commented 8 years ago

Hello, I just encountered this same issue. As vvmoppescapita said, just returning the response will mean the error callbacks never get executed because angular will treat all responses as successful.

JamesRandall commented 8 years ago

Agreed, silly mistake. Merged and bower version bumped up so you should be able to get it through a package update.

Thanks both.