feat(router): guard beforeLoad en /settings para client_editor y client_viewer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { lazy, Suspense, useEffect } from 'react'
|
import { lazy, Suspense, useEffect } from 'react'
|
||||||
import { createRouter, createRootRoute, createRoute, Outlet, useNavigate, useRouterState } from '@tanstack/react-router'
|
import { createRouter, createRootRoute, createRoute, redirect, Outlet, useNavigate, useRouterState } from '@tanstack/react-router'
|
||||||
import { WorkspacePageWithBoundary } from '@/features/workspace/WorkspacePage'
|
import { WorkspacePageWithBoundary } from '@/features/workspace/WorkspacePage'
|
||||||
import { ImportPage } from '@/features/import/ImportPage'
|
import { ImportPage } from '@/features/import/ImportPage'
|
||||||
import { LibraryPage } from '@/features/library/LibraryPage'
|
import { LibraryPage } from '@/features/library/LibraryPage'
|
||||||
@@ -131,6 +131,12 @@ const settingsRoute = createRoute({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
component: SettingsPage,
|
component: SettingsPage,
|
||||||
|
beforeLoad: ({ context }) => {
|
||||||
|
const role = (context as { auth?: { user?: { platformRole?: string } } }).auth?.user?.platformRole
|
||||||
|
if (role === 'client_editor' || role === 'client_viewer') {
|
||||||
|
throw redirect({ to: '/library' })
|
||||||
|
}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const resourcesRoute = createRoute({
|
const resourcesRoute = createRoute({
|
||||||
|
|||||||
Reference in New Issue
Block a user