Closed sazzer closed 8 years ago
This has nothing to do with lout, bring it to hapijs/discuss.
Apologies. I thought I was on discuss but must have gone from the wrong tab instead :-( sorry about that!
On Mon, 4 Jan 2016 22:38 Nicolas Morel notifications@github.com wrote:
Closed #146 https://github.com/hapijs/lout/issues/146.
— Reply to this email directly or view it on GitHub https://github.com/hapijs/lout/issues/146#event-505319887.
I'm writing my own Authentication Scheme to use with something I'm doing. For now it's just based off of hapi-auth-basic but that's just to get the hang of things.
I'm trying to get it so that I can return a custom payload on authentication failure, but at the same time support the route stating that authentication is optional. The best that I can find to support this is:
If error.isMissing is set to true - which it is automatically for Boom.unauthorized() - then it doesn't work correctly when the authorization fails (It instead rewrites the payload and you end up with a more typical Boom JSON structure than the one that I have provided here)
If you don't provide a Boom object at all - or an Error object which is automatically wrapped - then you can't have the authentication be optional - failure is always an error regardless of how the route is configured.
Is there some cleaner way to specify a custom error payload for failed authentication?