mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
Add condition
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
4edad86029
commit
85ea0abdc8
@ -3,10 +3,24 @@
|
||||
module.exports = {
|
||||
conditions: [
|
||||
{
|
||||
displayName: 'Is Creator',
|
||||
displayName: 'Is creator',
|
||||
name: 'is-creator',
|
||||
plugin: 'admin',
|
||||
handler: user => ({ created_by: user.id }),
|
||||
handler: user => ({ 'created_by.id': user.id }),
|
||||
},
|
||||
{
|
||||
displayName: 'Has same role as creator',
|
||||
name: 'has-same-role-as-creator',
|
||||
plugin: 'admin',
|
||||
handler: user => ({
|
||||
'created_by.roles': {
|
||||
$elemMatch: {
|
||||
id: {
|
||||
$in: user.roles.map(r => r.id),
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -117,13 +117,11 @@ module.exports = ({ models, target }, ctx) => {
|
||||
|
||||
if (!definition.uid.startsWith('strapi::')) {
|
||||
definition.attributes['created_by'] = {
|
||||
autoPopulate: false,
|
||||
model: 'user',
|
||||
plugin: 'admin',
|
||||
};
|
||||
|
||||
definition.attributes['updated_by'] = {
|
||||
autoPopulate: false,
|
||||
model: 'user',
|
||||
plugin: 'admin',
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user