Я думаю, что это сделает это.
server/boot/01-add-user.js
module.exports = (server) => {
// Before each create request, assign the userId property to the userId of the accessToken
const addUser = async (ctx) => {
function assignUserId(o) {
o.userId = ctx.req.accessToken.userId;
}
// You can post arrays of objects to loopback
if (Array.isArray(ctx.req.body)){
ctx.req.body.forEach(assignUserId);
} else {
assignUserId(ctx.req.body);
}
};
server.models.MY_MODEL.beforeRemote('create', addUser);
}
Для ваших ACL попробуйте это
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW",
"property": "create"
}
],