add prefix for role name

This commit is contained in:
Maidul Islam
2023-09-15 20:11:06 -04:00
parent 8cd6a1f564
commit 29da8843a3
+4 -4
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); const value = roleMap.get(key);
if (value) { if (value) {
value.membershipIds.push(membership._id.toString()); value.membershipIds.push(membership._id.toString());
@@ -766,14 +766,14 @@ export const backfillPermission = async () => {
for (const [key, value] of roleMap.entries()) { for (const [key, value] of roleMap.entries()) {
const { membershipIds, permissions, workspaceId, organizationId } = value const { membershipIds, permissions, workspaceId, organizationId } = value
const membership_identity = crypto.randomBytes(3).toString("hex")
const role = new Role({ const role = new Role({
name: "Migrated Role", name: `Migrated Role [${membership_identity.toUpperCase()}]`,
organization: organizationId, organization: organizationId,
workspace: workspaceId, workspace: workspaceId,
description: "This role was auto generated by Infisical in effort to migrate your project members to our new permission system", description: "This role was auto generated by Infisical in effort to migrate your project members to our new permission system",
isOrgRole: false, isOrgRole: false,
slug: `custom-role-${crypto.randomBytes(3).toString("hex")}`, slug: `custom-role-${membership_identity}`,
permissions: permissions permissions: permissions
}); });