mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +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 = {
|
module.exports = {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
displayName: 'Is Creator',
|
displayName: 'Is creator',
|
||||||
name: 'is-creator',
|
name: 'is-creator',
|
||||||
plugin: 'admin',
|
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::')) {
|
if (!definition.uid.startsWith('strapi::')) {
|
||||||
definition.attributes['created_by'] = {
|
definition.attributes['created_by'] = {
|
||||||
autoPopulate: false,
|
|
||||||
model: 'user',
|
model: 'user',
|
||||||
plugin: 'admin',
|
plugin: 'admin',
|
||||||
};
|
};
|
||||||
|
|
||||||
definition.attributes['updated_by'] = {
|
definition.attributes['updated_by'] = {
|
||||||
autoPopulate: false,
|
|
||||||
model: 'user',
|
model: 'user',
|
||||||
plugin: 'admin',
|
plugin: 'admin',
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user