add prefix for role name

This commit is contained in:
Maidul Islam
2023-09-15 20:11:06 -04:00
parent 8cd6a1f564
commit 29da8843a3

View File

@@ -753,7 +753,7 @@ export const backfillPermission = async () => {
}
});
const key = `${JSON.stringify(secretPermissions)}-${membership.workspace.organization.toString()}-${membership.workspace._id.toString()}`; // group roles that have same permission with in the same org and workspace
const key = `${JSON.stringify(secretPermissions)}-${membership.workspace._id.toString()}`; // group roles that have same permission with in the same workspace
const value = roleMap.get(key);
if (value) {
value.membershipIds.push(membership._id.toString());
@@ -766,14 +766,14 @@ export const backfillPermission = async () => {
for (const [key, value] of roleMap.entries()) {
const { membershipIds, permissions, workspaceId, organizationId } = value
const membership_identity = crypto.randomBytes(3).toString("hex")
const role = new Role({
name: "Migrated Role",
name: `Migrated Role [${membership_identity.toUpperCase()}]`,
organization: organizationId,
workspace: workspaceId,
description: "This role was auto generated by Infisical in effort to migrate your project members to our new permission system",
isOrgRole: false,
slug: `custom-role-${crypto.randomBytes(3).toString("hex")}`,
slug: `custom-role-${membership_identity}`,
permissions: permissions
});