So I have a model with some fields like so:
// ...
slug: {
type: 'string',
required: true,
alphanumeric: true,
minLength: 3,
maxLength: 16
},
loggedinAt: 'date',
// ...
I'm using the Sails blueprint structure so it automatically maps everything. However, sometimes I have fields like loggedinAt
which are strictly internal and I don't want them to be able to be set by the user.
As it stands if I make a post requests with the loggedinAt
field it will set it. How can I restrict this?
You can use a policy to restrict this behavior. In api/policies/restrictUserCreate.js:
or, to just ignore certain fields (Sails v0.10.x only), use the blacklist:
Then in config/policies.js: