Skip to content

Undefined Parse.User.current() for Cloud functions #301

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

Closed
laullon opened this issue Feb 8, 2016 · 3 comments
Closed

Undefined Parse.User.current() for Cloud functions #301

laullon opened this issue Feb 8, 2016 · 3 comments

Comments

@laullon
Copy link
Contributor

laullon commented Feb 8, 2016

Hi,

Parse.User.current() doesn't get setup for Cloud functions.

I had tired to put Parse.User.become(sessionToken) on Auth.js getAuthForSessionToken but it throw a exception:
[Error: It is not memory-safe to become a user in a server environment]

@gfosco
Copy link
Contributor

gfosco commented Feb 8, 2016

In a Node environment, it's not safe to use Parse.User.current, or become methods. You can pass a sessionToken to queries or saves to perform an operation as a user.

i.e.

query.find({ sessionToken: myToken }).then(....);
obj.save(null, { sessionToken: myToken }).then(....);

You can access the user making the request in the request.user object.

@laullon
Copy link
Contributor Author

laullon commented Feb 8, 2016

I understand that, but my problem is that I have a lot of functions that relay on current user, and it works on the hosted version....

Is the sessionToken global?

At least, this should be on the README.md under "Not supported".

@drew-gross
Copy link
Contributor

No, any global state would be shared between requests in Node.js, which wasn't the case on parse.com. You will have to update your Cloud Code. Good point about the readme, though, I will update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants