-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Parse.User.current() in cloud code #188
Comments
In hosted Parse each request loaded a whole instance of Cloud Code with no shared state, so Parse.User.current() made sense. In Node directly, like via webhooks or parse-server, the server stays running, so Parse.User.current() would be unstable. It is disabled in parse/node and the documented way of using users is to get the user from the request object, and pass session tokens directly to methods. See the Switching from Cloud Code to Node.js section here: http://blog.parse.com/learn/using-node-js-with-parse/ |
Thanks for the answer, I"m currently using parse": "~1.6.13" on the client and parse-server 2.0.4 for the server side. I'm getting TypeError: Cannot read property 'getSessionToken' of undefined when trying to use your example. It seems that req.user does not return a valid user. do I need to pass it when invoking the cloud code from the client? currently my client code looks like this: Parse.Cloud.run("funcation name", parameters) Thanks, |
Ah. It was landed in #172 but has not been released as a new version... There are 2 failing tests in master that I'm trying to clean up before tagging 2.0.5. You can make a similar change or just wait a bit longer. Thanks for your patience and understanding! |
@gfosco: I have been following this issue - all my cloud functions look for the session user in the request - they also look for install id. It seems none of this works. Looking above it looks like I can get a session token and use that. However I was following #172 which seems to fix the issue that the user was not passed to cloud fn's - is this fix now released? Appreciate your efforts. |
2.0.5 is out, let me know if this fixes things for you. |
@gfosco : Am i right in saying that all queries need to use the user session token? Do the acl's work: can you confirm? |
This fixed my issue, request.user is now available |
I'm getting the session token from the EDIT: Doh! Realized my error right after posting this question. I had forgot to require var Parse = require('parse/node').Parse; |
Looks like this is fixed. |
FIxed typo in page title.
Hi,
In my cloud code I'm using: var user = Parse.User.current(); this used to work correctly when running on Parse.com. now that I run it on my own server I get null back.
Thanks,
Simon
The text was updated successfully, but these errors were encountered: