gristow
gristow

Reputation: 45

Why can't I save() to this Parse.Object?

With the following code, I'm able to successfully create a Parse.Object, and view it in the databrowser:

// This code executes correctly:
var UPrefs = Parse.Object.extend("uPrefs");
var uPrefs = new UPrefs();
uPrefs.setACL(new Parse.ACL(Parse.User.current()));
uPrefs.save();

After the promise has been fulfilled, the current user can no longer update the object:

// But then this code throws a 403 error
uPrefs.save();

Here are the error details:

code: 119
"This user is not allowed to perform the update operation on uPrefs. You can
change this setting in the Data Browser."

Even though the data browser shows the ACL for the row set (w/ both read & write privileges) to the user who created it, and is then trying to update it.

Can anyone spot what I'm doing wrong?

Many thanks if you can help!

Upvotes: 1

Views: 498

Answers (1)

gristow
gristow

Reputation: 45

With thanks to WandMaker's comments for leading me in the right direction:

To solve this I needed to: - add a user column to the uPrefs Parse.Object model. - add a pointer to the user column in the class level permissions, and set that to have read/create/write/update/destroy permissions.

Once that's done, the following code works:

var UPrefs = Parse.Object.extend("uPrefs");
var uPrefs = new UPrefs();
uPrefs.set("user", Parse.User.current());
uPrefs.setACL(new Parse.ACL(Parse.User.current()));
uPrefs.save();

And then all future save() calls work as well.

Upvotes: 2

Related Questions