Skip to content

Commit

Permalink
fix: sanitize history versions data field (#20143)
Browse files Browse the repository at this point in the history
* fix: sanitize history versions data field

* fix: ts cannot be named error
  • Loading branch information
remidej committed Apr 22, 2024
1 parent 1fabb4e commit 7431ba9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default ({ action, ability, model }: any) => {
traverseEntity(omitHiddenFields, ctx),
// Remove not allowed fields (RBAC)
traverseEntity(removeDisallowedFields(permittedFields), ctx),
// Remove roles from createdBy & updateBy fields
// Remove roles from createdBy & updatedBy fields
omitCreatorRoles
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ const createHistoryVersionController = ({ strapi }: { strapi: Core.Strapi }) =>
...getValidPagination({ page: params.page, pageSize: params.pageSize }),
});

return { data: results, meta: { pagination } };
return {
data: await Promise.all(
results.map(async (result) => ({
...result,
data: await permissionChecker.sanitizeOutput(result.data),
}))
),
meta: { pagination },
};
},

async restoreVersion(ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface CreateHistoryVersion {
componentsSchemas: Record<`${string}.${string}`, Struct.SchemaAttributes>;
}

interface Locale {
export interface Locale {
name: string;
code: string;
}
Expand Down

0 comments on commit 7431ba9

Please sign in to comment.