refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Access Control lower cases resources intermittently

Open JoeGaffney opened this issue 1 year ago • 6 comments

Describe the bug

Sometimes resource names can get changed to lower case even though they are Camel cased.

            {
              name: "auditLogs",
              list: "/administration/auditLogs",
              show: "/administration/auditLogs/show/:id",
              meta: {
                icon: <></>,
                parent: "administration",
                label: "Audit Logs",
              },
            },

Will then appear as auditlogs in the access control Can method

Steps To Reproduce

Create a camelCase resouce.

Log the resource name in the accessControl.

export const accessControlProvider = {{ can: async ({{ resource, action, params }}) => {{ console.log(resource) console.log("Resource Name:", params?.resource?.name); ... }}, }};

Expected behavior

Not to change the casing

Packages

  • @refine-dev/core

Additional Context

Was mentioned on discord to put a ticket in @aliemir said he has a solution.

Potentially somehow related to kbar?

JoeGaffney avatar May 30 '24 14:05 JoeGaffney

Hey @JoeGaffney thanks for the issue. We are open to contributions for this one.

BatuhanW avatar Jun 03 '24 07:06 BatuhanW

Hey @BatuhanW i would like to work on this issue. can you please assign it to me?

JayBhensdadia avatar Jun 04 '24 15:06 JayBhensdadia

Hey @JayBhensdadia assigned to you.

Please make sure to thoroughly read and follow our contribution guide. PRs that doesn't follow our contribution guide, will be closed.

https://refine.dev/docs/guides-concepts/contributing/

BatuhanW avatar Jun 05 '24 07:06 BatuhanW

sure

JayBhensdadia avatar Jun 05 '24 09:06 JayBhensdadia

This issue is related with our sider components (ThemedSiderV2 etc.). In the <CanAccess /> wrappers of the menu items we're sending the resource.name with toLowerCase(). Since we don't have this transform in any other usages of useCan or <CanAccess /> I don't think this is going to be a breaking change because user already needs to handle both lower cased and non-transformed resource names 🤔

aliemir avatar Jun 06 '24 06:06 aliemir

ah that makes sense with the pattern I was seeing ( some cases changes and others not)

I did have a resource defined with only a show and not a list in the resources that was camel and was not affected. So would not appear in the side panel and thus probably not go through the canAccess first from the sider

JoeGaffney avatar Jun 06 '24 06:06 JoeGaffney