Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Update archetype rbac scopes #1624

Merged
merged 2 commits into from
Dec 15, 2023
Merged

Conversation

ibolton336
Copy link
Member

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good, just a comment about the style when building the items array.

Comment on lines +383 to +391
...(archetypeWriteAccess
? [
{
title: t("actions.duplicate"),
onClick: () =>
setArchetypeToDuplicate(archetype),
},
]
: []),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternate form would be to drop undefieneds and then .filter(Boolean) at the end...

         [
           archetypeWriteAccess && {
              title: ...
             ...
           },
           assessmentWriteAccess && { ... },
           ...
         ].filter(Boolean)

Comment on lines +282 to +286
const token = keycloak.tokenParsed;
const userScopes: string[] = token?.scope.split(" ") || [],
archetypeWriteAccess = checkAccess(userScopes, archetypesWriteScopes),
assessmentWriteAccess = checkAccess(userScopes, assessmentWriteScopes),
reviewsWriteAccess = checkAccess(userScopes, reviewsWriteScopes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is what we have to work with right now, but it pains me just a bit.

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because it works.

But the scope checking code is ugly and deserves to be refactored in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants