feat(survey): show the design survey to every admin
The survey screen, its nav item, route guard and API were gated on the product.survey rid, which only the super admin held in practice. Grant 'product' and 'product.survey' to every user type (migration for existing databases, seed for fresh ones). 'product' only opens the products menu group — its other children keep their own rids — so nothing else new becomes visible. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
387222851c
commit
5593cef462
@@ -0,0 +1,19 @@
|
|||||||
|
-- Product design survey visible to EVERY admin user, whatever their user type.
|
||||||
|
--
|
||||||
|
-- Before this, the survey screen (nav item, route guard, in-view check and the
|
||||||
|
-- API's @RequirePermission('product.survey')) only appeared for admins whose
|
||||||
|
-- user type had been granted `product.survey` — in practice the super admin.
|
||||||
|
--
|
||||||
|
-- Granting both rids to every existing user type fixes that:
|
||||||
|
-- `product` - the «محصولات» menu group itself (children are still
|
||||||
|
-- gated by their own rids, so nothing else new appears)
|
||||||
|
-- `product.survey` - the «نظرسنجی طرح» item and its API endpoints
|
||||||
|
--
|
||||||
|
-- Idempotent: re-running adds nothing. User types created later are granted
|
||||||
|
-- through the normal permission screen, and the seed does the same for fresh
|
||||||
|
-- databases.
|
||||||
|
INSERT INTO "permission" ("rid", "userTypeId")
|
||||||
|
SELECT r.rid, ut.id
|
||||||
|
FROM (VALUES ('product'), ('product.survey')) AS r(rid)
|
||||||
|
CROSS JOIN "user_type" AS ut
|
||||||
|
ON CONFLICT ("rid", "userTypeId") DO NOTHING;
|
||||||
@@ -88,6 +88,17 @@ async function seedAccessControl() {
|
|||||||
skipDuplicates: true,
|
skipDuplicates: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The design survey is for every admin, not only the super admin — see the
|
||||||
|
// 20261126120000_survey_visible_to_all_admins migration. `product` opens the
|
||||||
|
// «محصولات» menu group; its other children stay gated by their own rids.
|
||||||
|
const allTypes = await prisma.userType.findMany({ select: { id: true } });
|
||||||
|
await prisma.permission.createMany({
|
||||||
|
data: allTypes.flatMap((ut) =>
|
||||||
|
['product', 'product.survey'].map((rid) => ({ rid, userTypeId: ut.id })),
|
||||||
|
),
|
||||||
|
skipDuplicates: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user