fix(auth): handle zero-permission users gracefully and prevent redirect loops

This commit is contained in:
2026-08-11 07:36:01 +08:00
parent 04c12ad340
commit 2e02eee66c
6 changed files with 84 additions and 7 deletions
+13
View File
@@ -1,4 +1,5 @@
import type { LucideIcon } from 'lucide-react'
import { can } from '@/auth/store'
import {
BookOpenText,
Bot,
@@ -100,3 +101,15 @@ export const NAV_GROUPS: NavGroup[] = [
],
},
]
export function getFirstAccessibleRoute(): string | null {
for (const group of NAV_GROUPS) {
for (const item of group.items) {
if (!item.permission || can(item.permission)) {
return item.to
}
}
}
return null
}