2

I have Parse _User's with sensitive data on them, so I have the ACL's for Public Read/Write set to false. However, I want to allow users to get some of the user's data, such as their first/last name. I'm doing this through cloud code - where they poll for a user with a specific objectId, but when the cloud code returns, it will censor the sensitive data by changing the fields before it returns to the user. However, it appears that Parse considers this returning of objects "dirty," and refuses to return. Is there a way to return modified objects to users in this fashion (or any other fashion)?

For example, my user object has five (notable) fields.

+----------+-----------+----------+-----------+----------+
| objectId | firstName | lastName | birthdate | username |
+----------+-----------+----------+-----------+----------+
| aBcDeFgH | "Jason"   | "Bourne" | "4/15/71" | jbourne  |
+----------+-----------+----------+-----------+----------+

When I have it queried, I want to omit the birthdate. To do this in the cloud, I say something along the lines of...

var object = result // result of a Parse.Query.first function
object.set("birthdate", "censored")
return object

And I get the following error.

[Error]: Uncaught Tried to save an object with a pointer to a new, unsaved object. (Code: 141, Version: 1.8.2)
9
  • Did you try to use the master key? Commented Sep 13, 2015 at 18:46
  • I use the Parse.Cloud.useMasterKey() command to poll the server to bypass the ACL's - that isn't the problem. The problem occurs when I try to return an unsaved PFObject to the user without saving the PFObject - saving the PFObject would overwrite the fields that are still utilized. Commented Sep 13, 2015 at 18:52
  • Could you post the code? After 2000 lines of Cloud Code I built up a bit of experience ^^ Anyway you shouldn't return unsaved Parse Objects (please don't call them PFObjects unless you're talking about obj-c/swift code lol) Commented Sep 13, 2015 at 19:18
  • Force of habit. Updated original post with snippits. Commented Sep 13, 2015 at 19:22
  • This answer (the first one) from their forum might help you Commented Sep 13, 2015 at 19:31

1 Answer 1

2

There is (a quite old, but still applicable) answer in their forum.

The idea behind this is that since Parse prohibits unsaved (persistent) objects to be returned to the client, you just copy the object, edit the copy and return that instead. I hope that this makes sense.

Sign up to request clarification or add additional context in comments.

1 Comment

can you provide code? Copy an object is not clear. Do you mean you return an actual parse object or you return a JSON. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.