Skip to content

Commit

Permalink
skipWithMasterKey
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy authored Nov 11, 2020
1 parent 9b8846b commit 51bb51c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions _includes/cloudcode/cloud-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,16 @@ This function will only run if:
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.

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

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

Expand Down

0 comments on commit 51bb51c

Please sign in to comment.