修复会话安全与实时消息
This commit is contained in:
@@ -7,4 +7,32 @@ const RequireAuth = () => {
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export const RequirePlatformAdmin = () => {
|
||||
const { user } = useAuth()
|
||||
if (!user) return <Navigate to="/login" replace />
|
||||
if (user.role !== 'platform_admin') return <Navigate to="/agent/dashboard" replace />
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export const RequireStaff = () => {
|
||||
const { user } = useAuth()
|
||||
if (!user) return <Navigate to="/login" replace />
|
||||
if (user.role === 'platform_admin') return <Navigate to="/admin/dashboard" replace />
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export const RequireSupervisor = () => {
|
||||
const { user } = useAuth()
|
||||
if (!user) return <Navigate to="/login" replace />
|
||||
if (user.role !== 'admin' && user.role !== 'supervisor') return <Navigate to="/agent/dashboard" replace />
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export const RequireTenantAdmin = () => {
|
||||
const { user } = useAuth()
|
||||
if (!user) return <Navigate to="/login" replace />
|
||||
if (user.role !== 'admin') return <Navigate to="/agent/dashboard" replace />
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export default RequireAuth
|
||||
|
||||
Reference in New Issue
Block a user