how to pass custom params to access control of show page
I am using antdesign and nextjs. I have a show page like this
But from here how can i pass companyId to accesscontrol provider params?
2 Replies
Hi @Supa hot fire. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To pass the
companyId
to the access control provider for your show page, you have a few options. Let me explain how you can do this:
Option 1: Wrap your Show component with CanAccess
The most straightforward approach is to wrap your <Show>
component with the <CanAccess>
component and pass the companyId
as a parameter:
This approach allows you to explicitly pass the companyId
to the access control provider through the params
property of the <CanAccess>
component CanAccess Component.
Option 2: Disable built-in access control in Show and handle it manually
Another approach is to disable the built-in access control in the <Show>
component and handle it manually:
In this approach, you're using the useCan
hook to check permissions manually with your custom parameters useCan Hook.
How Access Control Works
When you use the <Show>
component, it internally checks for access control using the resource and action parameters. However, it doesn't automatically pass custom parameters like your companyId
.
In your access control provider implementation, you would handle these parameters like this:
This way, your access control provider can make decisions based on both the job ID and the company ID.
Remember that the params
object in your access control provider will contain all the parameters you pass to the <CanAccess>
component or the useCan
hook.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@541506908301819930> Kapa.ai is still learning and improving, please let me know how I did by reacting below.