diff --git a/backend/src/services/identity-project/identity-project-service.ts b/backend/src/services/identity-project/identity-project-service.ts
index a49b15c1bd..7f9cf920e1 100644
--- a/backend/src/services/identity-project/identity-project-service.ts
+++ b/backend/src/services/identity-project/identity-project-service.ts
@@ -182,7 +182,12 @@ export const identityProjectServiceFactory = ({
// validate custom roles input
const customInputRoles = roles.filter(
- ({ role }) => !Object.values(ProjectMembershipRole).includes(role as ProjectMembershipRole)
+ ({ role }) =>
+ !Object.values(ProjectMembershipRole)
+ // we don't want to include custom in this check;
+ // this unintentionally enables setting slug to custom which is reserved
+ .filter((r) => r !== ProjectMembershipRole.Custom)
+ .includes(role as ProjectMembershipRole)
);
const hasCustomRole = Boolean(customInputRoles.length);
const customRoles = hasCustomRole
diff --git a/backend/src/services/project-membership/project-membership-service.ts b/backend/src/services/project-membership/project-membership-service.ts
index 74b830c6df..b4826b54bf 100644
--- a/backend/src/services/project-membership/project-membership-service.ts
+++ b/backend/src/services/project-membership/project-membership-service.ts
@@ -280,7 +280,12 @@ export const projectMembershipServiceFactory = ({
// validate custom roles input
const customInputRoles = roles.filter(
- ({ role }) => !Object.values(ProjectMembershipRole).includes(role as ProjectMembershipRole)
+ ({ role }) =>
+ !Object.values(ProjectMembershipRole)
+ // we don't want to include custom in this check;
+ // this unintentionally enables setting slug to custom which is reserved
+ .filter((r) => r !== ProjectMembershipRole.Custom)
+ .includes(role as ProjectMembershipRole)
);
const hasCustomRole = Boolean(customInputRoles.length);
if (hasCustomRole) {
diff --git a/frontend/src/views/Project/IdentityDetailsPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx b/frontend/src/views/Project/IdentityDetailsPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
index 8e157fcab0..300114228f 100644
--- a/frontend/src/views/Project/IdentityDetailsPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
+++ b/frontend/src/views/Project/IdentityDetailsPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
@@ -50,11 +50,34 @@ export const IdentityRoleDetailsSection = ({
const handleRoleDelete = async () => {
const { id } = popUp?.deleteRole?.data as TProjectRole;
try {
- const updatedRole = identityMembershipDetails?.roles?.filter((el) => el.id !== id);
+ const updatedRoles = identityMembershipDetails?.roles?.filter((el) => el.id !== id);
await updateIdentityWorkspaceRole({
workspaceId: currentWorkspace?.id || "",
identityId: identityMembershipDetails.identity.id,
- roles: updatedRole
+ roles: updatedRoles.map(
+ ({
+ role,
+ customRoleSlug,
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }) => ({
+ role: role === "custom" ? customRoleSlug : role,
+ ...(isTemporary
+ ? {
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }
+ : {
+ isTemporary
+ })
+ })
+ )
});
createNotification({ type: "success", text: "Successfully removed role" });
handlePopUpClose("deleteRole");
diff --git a/frontend/src/views/Project/MemberDetailsPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx b/frontend/src/views/Project/MemberDetailsPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
index e854ebc592..5ff78360dc 100644
--- a/frontend/src/views/Project/MemberDetailsPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
+++ b/frontend/src/views/Project/MemberDetailsPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
@@ -61,10 +61,33 @@ export const MemberRoleDetailsSection = ({
const handleRoleDelete = async () => {
const { id } = popUp?.deleteRole?.data as TProjectRole;
try {
- const updatedRole = membershipDetails?.roles?.filter((el) => el.id !== id);
+ const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
await updateUserWorkspaceRole({
workspaceId: currentWorkspace?.id || "",
- roles: updatedRole,
+ roles: updatedRoles.map(
+ ({
+ role,
+ customRoleSlug,
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }) => ({
+ role: role === "custom" ? customRoleSlug : role,
+ ...(isTemporary
+ ? {
+ isTemporary,
+ temporaryMode,
+ temporaryRange,
+ temporaryAccessStartTime,
+ temporaryAccessEndTime
+ }
+ : {
+ isTemporary
+ })
+ })
+ ),
membershipId: membershipDetails.id
});
createNotification({ type: "success", text: "Successfully removed role" });
@@ -215,7 +238,10 @@ export const MemberRoleDetailsSection = ({
title="Roles"
subTitle="Select one or more of the pre-defined or custom roles to configure project permissions."
>
-
+