-
Notifications
You must be signed in to change notification settings - Fork 22
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
using server only session data in filter #29
Comments
I think you want something like this: // whitelisted query
r.table("trades").orderBy({index: allowSpecificFieldOrderBy(RP, "datetime")})
.filter(r.row("currency").eq(allowAnyString(RP)))
.filter(r.row("isExecuted").eq(true))
.filter(r.row('userId').eq(RP.ref('userId'))
.pluck("datetime", "rate", "id")
.changes({"includeInitial": true}).opt("db", r.db("cxihub"))
.validate(function (refs, session) {
return refs.userId === session.userId;
}) |
@mikemintz hello, thank you for your reply, the issue is that I do not have this userId on the frontend, so I send a token and it gives me userId inside session. I want to modify the incomining query to use it. so my frontend sends {userId: "token"} while what rethinkdb sees {userId: "abcd"} |
I have been playing a lot with the lbrary, I can see it converts data to binary buffer and sends to rethinkdb, I tried to interept that buffer, converted to string and replaced it to my desired value and then forwarded it, but it does not work, the connection just hangs. so I have been trying to find a suitable place in the library to modify the query beforeit is sent to the rethinkdb |
This is not currently possible without modifying the library, but it is one of the goals of #2. One approach would be to refactor I haven't fully thought this through, but I'm definitely open to ideas on refactoring so query rewriting is supported. |
Hello I have been trying to play with the code, find a workaround. I actually thought i succeded but that was not the case. look at this file https://github.com/Rohithzr/rethinkdb-ws-server/blob/077f41d31c97779d6f04d4c19445dbdae6ef2ffc/src/Connection.js#L127 |
Rather than doing string manipulations like |
You may also want to read through https://www.rethinkdb.com/docs/writing-drivers/ to get an idea of how the JSON is formatted, so it's more clear what part of the query you should manipulate. |
I have a situation where the user sends a token from client via query params and I use the same to validate the session and store the the userId in the RP session.
now I want to add this userId in the filter of a query but I dont have this id in the frontend.
So I am looking for a way to either
The text was updated successfully, but these errors were encountered: