national-gold
national-gold7mo ago

access control making lowercase my resources

I have a resource vehicleTypes, and the can function from my accesControlProvider is getting vehicletypes, and it happens in some of the request, not in all. How can I avoid this?
4 Replies
kapa.ai
kapa.ai7mo ago
Hi @Jaoc1811. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, it seems that there might be a case sensitivity issue with the resource names in your accessControlProvider. In one of the Github issues (https://github.com/refinedev/refine/issues/4852) related to Refine, a user reported a similar issue where the resource name was being converted to lowercase in some cases, causing inconsistencies. The user resolved this issue by converting the resource name to lowercase in the can function of the accessControlProvider before comparing it with the expected resource name. Here's the code snippet they used:
if (resource?.toLowerCase() === "user")
if (resource?.toLowerCase() === "user")
In your case, you could do something similar:
if (resource?.toLowerCase() === "vehicletypes")
if (resource?.toLowerCase() === "vehicletypes")
This will ensure that the comparison is case-insensitive and should resolve the issue. However, please note that this is a workaround and the underlying issue might still need to be addressed in the Refine framework. If this doesn't solve your issue, I would recommend opening a new issue in the Refine Github repository (https://github.com/refinedev/refine/issues) to get help from the maintainers and the community. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@110864105035808768> kapa.ai is still learning and improving, please let us know how it did by reacting below
xenial-black
xenial-black7mo ago
Hey @Jaoc1811, if you can provide more info about the issue and when it happens, please open up an Github issue so we can investigate it further. For now as a workaround, you can check out the params that is passed to the can method, it should contain the resosurce object that you can find it with proper name and other meta data.
national-gold
national-gold7mo ago
Hi! I used the workaround that kapa.ai gave me I'll try to open an issue, but for now, I can tell that it happens only with the check of list-vehicleTypes from the sidemenu. Instead of getting vehicleTypes as a resource, I'm getting vehicletypes In all the other checks it appears to be vehicleTypes