-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Using the master key in a save hook #1658
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
This is already covered in the migration guide, specifically in the document that covers compatibility issues between hosted Parse and Parse Server. We highly recommend going through each section to make sure your app transitions to Parse Server smoothly. You may use Server Fault for questions about managing Parse Server. For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow. |
Thanks for the reply. I have read that guide and it says to use "useMasterKey: true" however I have not seen an example as the one I posted above with "useMasterKey: true" inside the function. This is the reason why I have posted here. |
Apologies, I misread your question. As a reminder you can use three backticks ( If I understood correctly, you're asking for the proper way of implementing the following in Parse Server, given that Parse.Cloud.beforeSave(Parse.Installation, function(req, res) {
Parse.Cloud.useMasterKey();
if (request.user) {
request.object.set('user', request.user);
} else {
request.object.unset('user');
}
response.success();
}); |
Yes sir. That is correct. |
In this specific example you posted, I don't think you need to use the master key at all. The save should complete as expected, since the user updating their current installation should have write access to it. |
Why would this exact code be on the Parse "AnyPic" example page if the Master Key isn't needed?? |
That's a great question. I don't think it is needed. Did you find otherwise? |
I am not entirely sure because i cannot seem to get my app to receive the direct notifications even though the logs have no errors and the database shows an increased counter in the "installation" section |
I don't think the above code will work, I am currently using without the master key. I have logged in with another device and noticed that the same user had a second 'installation' row in the database. Any ideas?? |
I have watched this video and I understand the way of using the master key On Sat, May 7, 2016 at 3:21 PM, Adam Farag [email protected] wrote:
Julius Btesh |
You can read the Javascript API documentation and you will see you can do it like 4 different ways I've tested this and it works: object.save(null, { useMasterKey: true }); |
@innopage that does not directly address the issue, as this is a My original point still stands -- I don't think it is necessary in the specific use case brought up by @D34THSTALKER, and I haven't seen any evidence to the contrary yet. |
@hramos I'm having a similar issue.. I have a object that was being created by a particular user and the ACL was set to them for this object. Another use can accept that reservation and it sets them as a pointer on the original object. Before migrating to parse server, I created a cloud function and used Now as I'm migrating to parse server I've removed the calls to If I log In my cloud function it's querying the object without any issues with passing p.s. my beforeSave isn't doing anything other then logging request.master here. parse 1.8.5 **edit: My bad, the second param is options on save.. For anyone else make sure to do:
|
Closing due to lack of activity, please update to latest parse-server version and reopen if the issue persist. Don't forget to include your current:
|
@Syttr Your post just saved my week. I would never have thought to add null as the first parameter of the save call. |
I am trying to refer to the Cloud Code example given for "beforeSave(Parse.Installation" and the function calls Parse.Cloud.useMasterKey(); But with the new Parse Server setups for the open source deployment, I read that I cannot use that line for using Mater Key anymore. How can I add that into this part of the function?
if (request.user) { request.object.set('user', request.user); } else { request.object.unset('user'); } response.success();
Thanks!
The text was updated successfully, but these errors were encountered: