-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
useMasterKey in cloudCode not working as expected #37
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
Comments
#13 In the top of the cloud code file, try:
|
No such luck, it's worth adding that I'm getting errors on .save() of ParseObjects as well. |
Will take a look at this... |
+1. I can't .save() objects in Cloud Code via parse-sever if it requires useMasterKey(). In a beforeSave() function if I return success() early (before I create/save a protected object) it works fine, but if the code to create/save a sub-object runs I get an error:
EDIT: I found the answer to my problem: #132 |
Much like how Parse.User.current() is invalid in a node script, because of the global nature, so is Parse.Cloud.useMasterKey(), because it is global and it would cause other requests to use the master key even if it was not intended. The correct approach is to always pass a In a save call, the options block is the second param:
In a query, it's the first.
Please update your code to follow this and open a new issue if you have problems. Thank you! |
@gfosco you should move this info to the guide imho. some people like myself with not a lot of node js experience will find it helpful |
I have the same problem, I tried to use @gfosco answer but I think I did it wrong. Could you help me? I read https://github.com/ParsePlatform/Parse-Server/wiki/Compatibility-with-Hosted-Parse#Cloud-Code too but it doesn't seem to work.
PS: This is the original code, I can give you what I tried if you want. EDIT: Problem solved. |
@OxyFlax It would be great if you shared what you did to make your code above work. |
@gfosco What should be the syntax for setting
because for push notifications, we don't call |
@gfosco I would also need to know the new syntax about useMasterKey: true if I would like to use it on So for push... Thanks much for feedback and best regards, |
@OxyFlax Can you please post your solution/ fix done? |
I have the same problem as @khanamir – seemingly no way to just set an option? I need to rewrite this to pass in Parse.Cloud.useMasterKey();
var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.equalTo('user', user);
Parse.Push.send({
where: installationQuery,
data: { ... }
},
{
// Would passing in `useMasterKey: true` here make the query
// passed into the `where` above use the master key?
// useMasterKey: true, ?
success: function() {},
error: function() {}
}); /cc @OxyFlax |
Alongside success and error, as you commented |
Same Error I am Getting Here ::: ==> Parse.Cloud.define("assignPasswordToUser", function(request, response){ |
Stop using |
Parse.Cloud.define("assignPasswordToUser", function(request, response){
}); Using This Gives Me An Error |
error: Failed running cloud function assignPasswordToUser for user undefined with: I Am Getting This Error When Using this Function Parse.Cloud.define('assignPasswordToUser', function(request, response) { |
Parse.Query().get takes an objectId as a parameter not a username |
I would just like to add that we were using What changed for this to break? If |
The depreciation notice has been added on Dec 7th: https://github.com/ParsePlatform/parse-server/blob/master/src/cloud-code/Parse.Cloud.js#L64 and 025e7a3 This should have been deprecated at an earlier date, sorry for the inconvenience. |
I am having trouble finding documentations for the change, the link everyone uses that links to the github wiki no longer works. Can I get the updated url for the documentation for this change? Thanks |
@flovilmart the link you posted is broken and returning a 404. What about for My example: query.find({
success: function(posts) {
Parse.Cloud.useMasterKey();
Parse.Object.destroyAll(posts, {
success: function() {
}
})
}
}); |
@flovilmart thanks for the updated link, but can you answer my question above about the proper use of EDIT: Fixed with the following code query.find({
success: function(posts) {
Parse.Object.destroyAll(posts, {useMasterKey: true});
}
}); |
We had some Cloud Code like this in Parse:
It worked fine in Cloud Code however, it seems to be broken in parse-server, on debugging it looks like
Parse.Cloud.useMasterKey();
is not being applied to the options of all ParseObject calls. This is required because the ACL prevents anyone creating additional items in the table.The text was updated successfully, but these errors were encountered: