mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Refactor code to run the query only when necessary
This commit is contained in:
parent
84130ab541
commit
32e4aec852
@ -194,10 +194,8 @@ const findEntityAndCheckPermissions = async (ability, action, model, id) => {
|
|||||||
|
|
||||||
const pm = strapi.admin.services.permission.createPermissionsManager({ ability, action, model });
|
const pm = strapi.admin.services.permission.createPermissionsManager({ ability, action, model });
|
||||||
|
|
||||||
const author = await strapi.admin.services.user.findOne(
|
const creatorId = _.get(file, [CREATED_BY_ATTRIBUTE, 'id']);
|
||||||
_.get(file, [CREATED_BY_ATTRIBUTE, 'id'], ''),
|
const author = creatorId ? await strapi.admin.services.user.findOne(creatorId, ['roles']) : null;
|
||||||
['roles']
|
|
||||||
);
|
|
||||||
|
|
||||||
const fileWithRoles = _.set(_.cloneDeep(file), 'createdBy', author);
|
const fileWithRoles = _.set(_.cloneDeep(file), 'createdBy', author);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user