waiting-for-dev / warden-jwt_auth

JWT token authentication with warden
MIT License
113 stars 56 forks source link

Add ability to customize error messages #39

Closed richardboehme closed 2 years ago

richardboehme commented 2 years ago

Hey! Thanks for the great gem!

It would be cool if it's possible to customize the error messages thrown for example by the UserDecoder class. My idea would be to make these messages configurable through the configuration of this gem. If the general idea gets approved I'd be happy to help out by working on this!

Use Case:

I'm currently using this gem together with devise-jwt and would like to get a consistent API error message schema. To be precise I'd like to overwrite the 'revoked token' message. My current work around is to define a custom failure app for warden and overwrite the message manually. Ideally it would be great to overwrite the message in warden-jwt_auth to remove the work around.

waiting-for-dev commented 2 years ago

Hey @richardboehme, thanks for your predisposal to help. UserDecoder doesn't render any error message. It raises an exception, so it's Devise or your app the one that is catching it and decorating it as an error message. It's there where you need to adjust the format.

richardboehme commented 2 years ago

Hey @waiting-for-dev I think you are right. My issue might be pretty devise-specific because they expect a symbol as the warden failure message to translate it using i18n. All in all I guess my workaround with the custom warden failure app might be the proper solution to my problem!