Closed
Description
- You've met the prerequisites: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#prerequisites.
- You're running the latest version of Parse Server: https://github.com/ParsePlatform/parse-server/releases
- You've searched through existing issues: https://github.com/ParsePlatform/Parse-Server/issues?utf8=%E2%9C%93&q=is%3Aissue Chances are that your issue has been reported or resolved before.
Environment Setup
- Server: 2.2.10 running on Dokku on AWS
- Database: Remote, Mongo 3.0, also on AWS
Steps to reproduce
- Setup a
beforeSave
hook for some class, let's sayEvent
; - Create/Save an object, without setting the properties
foo
andotherKey
with no changes, but setting a third one,thirdKey
for example, to some value. - Add the following code sample:
Code sample
Parse.Cloud.beforeSave("Event", function(request, response) {
var event = request.object;
console.log(event.dirtyKeys());
if(!request.master) {
var protectedKeys = ["foo", "otherKey"]; //only masterKey can change the protectedKeys
for (i = 0; i < protectedKeys.length; i++) {
var key = protectedKeys[i];
if (event.dirty(key)) {
response.error("External users are not authorized to change the key '" + key + "'. It's value is: (" + event.get(key) + "). Dirty keys are: " + event.dirtyKeys());
return;
}
}
}
});
Result
This same code works totally fine in the hosted Parse.com Cloud Code.
Unfortunately, event.dirty('foo')
returns true
, while dirtyKeys()
does not contain the property 'foo'. I show an alert in my app when this error happens, and we can see the error:
Mentioning @nlutsenko as he worked on dirtyKeys
and beforeSave
on #614 and @drew-gross on beforeSave
on #1884
Metadata
Metadata
Assignees
Labels
No labels