accessControlProvider is set first but login is done afterwards so I get role afterwards
accessControlProvider is set first but login is done afterwards so I get role afterwards
4 Replies
Hi @saarthak08. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, the
accessControlProvider
is indeed set up before the login process. However, the accessControlProvider
's can
method, which is used to control access, is called asynchronously. This means it doesn't execute immediately when the app loads, but rather when an access control check is needed.
In the login process, you would typically store the user's role in the local storage or another similar place. Then, in the can
method of the accessControlProvider
, you would retrieve the role from where you stored it and use it to determine access. Here's an example from the extracts:
In this example, the user's role is retrieved from local storage and used to determine access. This way, even though the accessControlProvider
is set up before login, it can still use the role that is obtained after login.
For more details, you can refer to the Access Control Provider documentation (https://refine.dev/docs/api-reference/core/providers/accessControl-provider/) and the Access Control tutorial (https://refine.dev/docs/advanced-tutorials/access-control/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@783220602336444416> kapa.ai is still learning and improving, please let us know how it did by reacting below
rare-sapphire•2y ago
Hello @saarthak08 what is your problem exactly?
equal-aquaOP•2y ago
Hey @batuhanw thanks for replying. It is resolved now