-
Notifications
You must be signed in to change notification settings - Fork 100
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
How to access the current "request" from within "validateFunc"? #58
Comments
No, will not have access to the request. But you could use a combination of auth and the |
And what is the reason not having access to the request in We have bit different use case - where we have database connection handler per request, which is accessible from request object - so it would be handy for us to be able to access the request object. |
Is that database connection going to be used to validate the request? |
It would be used to validate that token inside cookie is still valid - by checking sessions in database. |
To provide bit more context - we are using hapi-node-postgres, which provide connection from pool to every request and return connection back to the pool once request is finished. |
Is there anyway to define the validation function such that it has a reference to the connection pool? If not, the only solution is to change the signature of |
Do you think that passing request as last parameter would be acceptable? It would not be breaking change and it would help for use cases when you need to access request object. |
@hueniverse Do you have any concerns about passing the request object to On Mon, May 25, 2015, 4:35 AM Jarda Kotěšovec notifications@github.com
|
No, just need to find a way to minimize breaking changes. Not sure this is worth an option but this is a heavily used module and most people don't need this. |
@hueniverse If most people don't need this, is there a more common pattern for validating the session against a database while using a connection pool shared by the entire app? @jardakotesovec Instead of adding it as the last argument, adding it as an optional argument makes more sense to me. Would you like to throw together a PR? If not, let me know and I'll put something together. |
@jaw187 Not sure how you would make it as optional argument - based on some option? Maybe it could be passed via And if you could look into it that would be awesome.. 👍 |
I have a feeling we need to make this change across the three auth modules and just suck up the breaking changes. Maybe line it up with the upcoming hapi 9.0 which will include a few minor breaking changes. People have asked for access to the |
Ok. @hueniverse would you prefer multiple arguments or a single |
other than adding |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
I'm wondering whether it is possible to access the current "request" object from within the "validateFunc" callback function, for instance to check a contained IP address against the IP address of the requesting client? Is there a way I've overlooked? I would have expected that either the "request" object is passed into "validateFunc" as an additional parameter or that the "session" object has a backreference to the "request" object (perhaps directly via "session.request")...
The text was updated successfully, but these errors were encountered: