feathersjs-ecosystem / authentication-oauth2

[MOVED] OAuth 2 plugin for feathers-authentication
https://github.com/feathersjs/feathers
MIT License
26 stars 15 forks source link

Allow a custom error Handler #79

Closed mrdj07 closed 6 years ago

mrdj07 commented 6 years ago

I'd really need a way to customize the error redirect callback, based on the caught exception that triggered the fail. Simply allowing to have a custom errorHandler passed to the oauth() method when setting my authentication would allow me to do that.

This should be added to the documentation also.

daffl commented 6 years ago

This definitely makes sense, thank you for the pull request! Unfortunately, the tests are failing with

TypeError: options.errorHandler is not a function

You can run the tests locally with npm install and then npm test.

The most likely case is that https://github.com/feathersjs/authentication-oauth2/pull/79/files#diff-6d186b954a58d5bb740f73d84fe39073R69 should really be:

const errorHandler =  typeof options.errorHandler === 'function' ? 
  options.errorHandler(oauth2Settings) :
  defaultErrorHandler(oauth2Settings);
daffl commented 6 years ago

Great, thank you! Released as v1.1.0