mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 02:16:03 +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 author = await strapi.admin.services.user.findOne(
|
||||
_.get(file, [CREATED_BY_ATTRIBUTE, 'id'], ''),
|
||||
['roles']
|
||||
);
|
||||
const creatorId = _.get(file, [CREATED_BY_ATTRIBUTE, 'id']);
|
||||
const author = creatorId ? await strapi.admin.services.user.findOne(creatorId, ['roles']) : null;
|
||||
|
||||
const fileWithRoles = _.set(_.cloneDeep(file), 'createdBy', author);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user