genetic-orange
genetic-orange•15mo ago

How to show on the Web App from the server only the records created by the user that is logged in?

I want that the user that is logged in can view only the records created by him in that specific account. Because at the moment if I log in with a user or other different user I can see all the records created by the other users. That's not exactly what I want. Can you please help me? Thank you
8 Replies
kapa.ai
kapa.ai•15mo ago
Hi @ging_freecs. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai•15mo ago
---------------------- Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine documentation on Access Control (https://refine.dev/docs/advanced-tutorials/access-control) and Access Control Provider (https://refine.dev/docs/core/providers/accessControl-provider/) to help you implement the desired functionality. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•15mo ago
<@296624290843983873> kapa.ai is still learning and improving, please let us how it did by reacting below
manual-pink
manual-pink•15mo ago
I am in the same situation... I can get the logged-in user information with: const { data: user } = useGetIdentity<IUser>(); but I don't know how to query the server to retrieve let's say Posts, but only the posts that were created by the logged-in user by passing a parameter to the server like 'userId'... I would expect to be able to query something like: http://localhost:5001/posts?userId=6457428c639b288b199300c5 for that I am trying to modify the PostsList autogenerated by the MuiInferencer by playing with useMany, but haven't managed to yet
genetic-orange
genetic-orange•15mo ago
Exactly. I am still trying to figure out how to do it. Because someone says that the solution could be to send the access token to the server side and from there you query the posts where the creator was the Id of that logged in user.
manual-pink
manual-pink•15mo ago
but even in that case... you still have to pass to the server the access token... so at the end whether it's the access token or the userId we need to understand how to modify the query from refine client to the server to be able to pass a param (easily) all this, while trying not to create our own DataProvider but just use the out-of-the-box DataProvider like REST should be very easy, but I've spent hours searching and even asking ChatGPT and BingAI and the responses they give don't work either, they fail to give the right props to the Refine's useHooks I cannot understand why this isn't asked more or documented.. couldn't find any discussion online or an example in the Refine examples...
conscious-sapphire
conscious-sapphire•15mo ago
Hey guys 👋🏻 You can use ‘useTable’ using permanent filters and ‘queryOptions.enabled’ option. You can check out this example: https://refine.dev/docs/examples/multi-tenancy/strapi-v4/
Strapi-v4 | refine
In this example, we've shown how to build a Multi-Tenant app using the Strapi-v4 and refine in a simple manner. You can learn more by taking a look at the Live Example and reading the refine Strapi-v4 Multi-Tenancy Guide.
manual-pink
manual-pink•15mo ago
thanks! @salihozdemir will def have a deep look! I just had a quick peek and definitely looks promising! many thanks