toymachiner62 / hapi-authorization

ACL plugin for hapijs
MIT License
80 stars 25 forks source link

Route validation called after #11

Closed tomzaoral closed 8 years ago

tomzaoral commented 8 years ago

Hello there! We are using this Hapi plugin together with Joi validation. The problem is, when using aclQuery, the Joi validation is called after and therefore the parameter which is used in our aclQuery method is invalid (or doesn't exist) and calling this method is pointless.

The solution would be to use Hapi extension point onPreHandler instead of onPostAuth (you can find here). The difference between these two lifecycle points is that onPreHandler is called after path parameters, query and payload is validated.

I tried to change it manually and it seems it works as expected. If there is no problem with this change, would you accept PR with that?

toymachiner62 commented 8 years ago

I would accept a PR with that. I actually haven't messed with the aclQuery stuff much since i forked this project so if you send a PR along with a test/tests for the aclQuery changes you're proposing that'd be great.

toymachiner62 commented 8 years ago

Fixed by https://github.com/toymachiner62/hapi-authorization/pull/12