Skip to content

Commit 51bb51c

Browse files
authored
1 parent 9b8846b commit 51bb51c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

_includes/cloudcode/cloud-code.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,16 @@ This function will only run if:
197197
However, the requested user could set 'accType' to reviewer, and then recall the function. Here, you could provide validation on a `Parse.User` `beforeSave` trigger. `beforeSave` validators have a few additional options available, to help you make sure your data is secure.
198198

199199
```javascript
200-
Parse.Cloud.beforeSave(Parse.User, () => {
201-
// any additional beforeSave logic here
200+
Parse.Cloud.beforeSave(Parse.User, (request) => {
201+
// any additional beforeSave logic here. With skipWithMasterKey, if a masterKey is used, request.object will be returned, and this code won't run.
202202
}, {
203203
fields: {
204204
accType: {
205205
default: 'viewer',
206206
constant: true
207207
},
208208
},
209+
skipWithMasterKey: true
209210
});
210211
```
211212
This means that the field `accType` on `Parse.User` will be 'viewer' on signup, and will be unchangable, unless `masterKey` is provided.
@@ -217,6 +218,7 @@ The full range of built-in Validation Options are:
217218
- `validateMasterKey`: whether the validator should run on `masterKey` (defaults to false).
218219
- `fields`: an `Array` or `Object` of fields that are required on the request.
219220
- `requireUserKeys`: an `Array` of fields to be validated on `request.user`.
221+
- `skipWithMasterKey`: whether the trigger should "skip" if `masterKey` is provided.
220222

221223
The full range of built-in Validation Options on `.fields` are:
222224

0 commit comments

Comments
 (0)