You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of defining the same lists of roles all accross our front-end code, we should define them in a commom place (permissionConstants) and always reference them from there.
Also, we have ended up with multiple versions a role-checking util function (utils.hasRole, teamUtils.checkRole, and communityUtils.checkRole). Lets consolidate them into util.hasRole and delete the others.
🕵️ Details
We check user roles in more and more places on the frontend, mostly as a property for the RequireAuth component, but in other cases as well. The list of roles is maintained separately in the code in each location, even though they reflect a smaller number of conceptual permission groups.
For example, we need to check the same list of roles to see if a user can access a page component wrapped in RequireAuth, if they can see a link to that page in the dashboard, and if they can see a link to that page in the nav menu. So we should define the list of roles once in permissionConstants and refer to it everywhere else.
🙋♀️ Proposed Solution
Add functionality to utils.hasRole to match teamUtils.checkRole and communityUtils.checkRole. Specifically, if an empty list of permissions is passed in, it always returns true, and it accepts an optional third arg, teamableId, which is compared to roleAssignment.teamable.id.
Delete the checkRole functions and replace with calls to hasRole.
Replace basically every instance of a reference to ROLE_NAME with a reference to permissionConstants, adding groups to permission constants as needed. (There may be a few places where it makes sense to do otherwise.)
🌎 Localization
✅ Acceptance Criteria
Add functionality to utils.hasRole to match teamUtils.checkRole and communityUtils.checkRole
if an empty list of permissions is passed in, it always returns true
it accepts an optional third arg, teamableId, which is compared to roleAssignment.teamable.id
Delete the checkRole functions and replace with calls to hasRole
Replace basically every instance of a reference to ROLE_NAME with a reference to permissionConstants, adding groups to permission constants as needed. (There may be a few places where it makes sense to do otherwise.)
🛑 Blockers
The content you are editing has changed. Please copy your edits and refresh the page.
♻️ Debt/Refactor
Instead of defining the same lists of roles all accross our front-end code, we should define them in a commom place (permissionConstants) and always reference them from there.
Also, we have ended up with multiple versions a role-checking util function (utils.hasRole, teamUtils.checkRole, and communityUtils.checkRole). Lets consolidate them into util.hasRole and delete the others.
🕵️ Details
We check user roles in more and more places on the frontend, mostly as a property for the RequireAuth component, but in other cases as well. The list of roles is maintained separately in the code in each location, even though they reflect a smaller number of conceptual permission groups.
For example, we need to check the same list of roles to see if a user can access a page component wrapped in RequireAuth, if they can see a link to that page in the dashboard, and if they can see a link to that page in the nav menu. So we should define the list of roles once in permissionConstants and refer to it everywhere else.
🙋♀️ Proposed Solution
utils.hasRole
to matchteamUtils.checkRole
andcommunityUtils.checkRole
. Specifically, if an empty list of permissions is passed in, it always returns true, and it accepts an optional third arg, teamableId, which is compared to roleAssignment.teamable.id.ROLE_NAME
with a reference topermissionConstants
, adding groups to permission constants as needed. (There may be a few places where it makes sense to do otherwise.)🌎 Localization
✅ Acceptance Criteria
utils.hasRole
to matchteamUtils.checkRole
andcommunityUtils.checkRole
ROLE_NAME
with a reference topermissionConstants
, adding groups to permission constants as needed. (There may be a few places where it makes sense to do otherwise.)🛑 Blockers
Blocked By
The text was updated successfully, but these errors were encountered: