Skip to content

Parse.Cloud.useMasterKey whit sessionToken #487

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
flessard opened this issue Feb 18, 2016 · 2 comments
Closed

Parse.Cloud.useMasterKey whit sessionToken #487

flessard opened this issue Feb 18, 2016 · 2 comments

Comments

@flessard
Copy link
Contributor

In cloud function, if you set Parse.Cloud.useMasterKey() at the begin of your code and at the end of your code you call a other cloud function but you want to run this whit a user session, you need to pass the sessionToken.

Parse.Cloud.useMasterKey();

...

return Parse.Cloud.run('getUserRole', data, {
     sessionToken: request.user.getSessionToken()
});

Because you have set Parse.Cloud.useMasterKey at the begin of your code, your cloud function you try to run whit user session will run as master.

Why sessionToken does not override the masterKey if present ?

@gfosco
Copy link
Contributor

gfosco commented Feb 18, 2016

On hosted Parse? In parse-server, or node in general, Parse.Cloud.useMasterKey is not available... You must pass the sessionToken:token or useMasterKey:true options to the save/query/run calls.

@flessard
Copy link
Contributor Author

In parse-server.

In this example, the function getUserRole is run as master even if you pass a sessionToken because useMasterKey is set whit Parse.Cloud.useMasterKey()

In my opinion, if the sessionToken is present, the masterKey will not use.

Parse.Cloud.define("setUserRole", function(request, response) {

   Parse.Cloud.useMasterKey();

   ...

   return Parse.Cloud.run('getUserRole', data, {
        sessionToken: request.user.getSessionToken()
   });

   ...

});

Parse.Cloud.define("getUserRole", function(request, response) {
   // request.master == true 
  // request.user == undefined, is not supposed to be undefined because sessionToken is passed.

})

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

2 participants