fix: align dashboard guard with fallback menu access
Build & Deploy / Build & Push Docker Image (push) Successful in 2m46s
Test / Type Check (all packages) (push) Successful in 53s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Successful in 49s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 41s
Test / API Integration Tests (push) Successful in 1m1s

This commit is contained in:
root
2026-07-02 03:18:42 -04:00
parent ea2bd215f6
commit e93b988146
2 changed files with 32 additions and 1 deletions
@@ -39,6 +39,8 @@ const BASELINE_MENU_ROUTES = [
{ route: '/settings', minRole: 'OWNER' },
] as const
const MENU_RECOVERY_ROUTES = new Set(['/subscription', '/subscription/success', '/subscription/cancel'])
function hasMinRole(employeeRole: string, minRole: string): boolean {
return (ROLE_RANK[employeeRole] ?? 0) >= (ROLE_RANK[minRole] ?? 0)
}
@@ -65,9 +67,10 @@ export function flattenInternalRoutes(items: GeneratedMenuItem[]): string[] {
export function resolveAllowedRoutes(menu: EmployeeMenuResponse, role: string): string[] {
const routes = flattenInternalRoutes(menu.items)
const featureRoutes = routes.filter((route) => route !== '/' && !MENU_RECOVERY_ROUTES.has(route))
const shouldUseBaselineFallback =
menu.subscriptionAccessLevel !== 'none' &&
(routes.length === 0 || routes.every((route) => route === '/'))
featureRoutes.length === 0
return shouldUseBaselineFallback ? getBaselineInternalRoutes(role) : routes
}