Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change handleError to throw or call next if not OAuthError #31

Open
chainlink opened this issue Nov 9, 2016 · 1 comment
Open

Change handleError to throw or call next if not OAuthError #31

chainlink opened this issue Nov 9, 2016 · 1 comment

Comments

@chainlink
Copy link

If the error encountered is not expected (ie. not an OAuth Library error) it should re throw the error (or at least pass it to next to be dealt with)

https://github.com/oauthjs/express-oauth-server/blob/master/index.js#L142

I propose checking if it's an instance of https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/oauth-error.js

If you agree I can prepare a PR

@maxtruxa
Copy link
Member

None of the middlewares exported by OAuth2Server ever return an unknown error type. Unknown errors are always wrapped using ServerError (#authenticate, #authorize, #token).

With #19 merged you can initialize the server like this:

new OAuthServer({
  model: ...,
  useErrorHandler: true
});

which tells express-oauth-server to forward errors using next(err) instead of sending a response by itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants