import { NotAuthorizedError } from "@webiny/api-security" ; import { SecurityIdentity } from "@webiny/api-security/types" ; export default ( identity , permission , entity , entityField = "createdBy" ) : void => { if ( permission && permission . own === true ) { if ( entity [ entityField ] . id !== identity . id ) { throw new NotAuthorizedError ( ) ; } } } ;