fix(access): honor finance sections and team-member data scope

Role treasury keys now open the first allowed finance page, and team-member ownership limits lists, dashboard, and reports instead of the whole organization.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-09 11:20:20 +03:30
co-authored by Cursor
parent 3c9b906bd6
commit 0e1bc4a1fe
15 changed files with 243 additions and 64 deletions
+16
View File
@@ -636,6 +636,22 @@ export function parseUserTreasuryAccess(raw: unknown): UserTreasuryAccess | null
};
}
/**
* دسترسی مالی کاربر، اگر تنظیم شده باشد، کلیدهای مالی نقش را جایگزین می‌کند.
* null یعنی همان مجوزهای نقش.
*/
export function permissionsWithTreasuryOverride(
rolePermissions: readonly string[],
override: UserTreasuryAccess | null,
): string[] {
if (!override) return [...rolePermissions];
const rest = rolePermissions.filter(
(key) => key !== "treasury" && !key.startsWith("treasury_"),
);
if (!override.enabled) return rest;
return ["treasury", ...override.sections, ...rest];
}
export function emptySectionDataAccess(): SectionDataAccess {
return { mode: "all", rules: [] };
}