I'm currently trying to add middleware in Strapi so that when a user utilizes the core "find" method on a collection, they only see records they own.
I've already implemented a middleware that works for "update" and "delete" methods based on this documentation. However, I can't seem to adapt this example for the "find" method as I can't manipulate the query.
Of course, I have the option to create a custom route to accomplish this, but it would be much more efficient to apply this to existing routes for easier maintenance.
Any insights on how to achieve this?
I already tried to get the result of the controller using await next(); to then filter manually the result; but there aren't all the necessary field to filter the data like that, and I don't want theses field to appears to the user.
ctx.queryobject, before await next, and appendownerto it query. E.gctx.query = {…ctx.query, filter: { owner: { id: user.id }}};