teg/frontend/src/components/permissions.ts
2026-05-19 18:07:22 +02:00

15 lines
400 B
TypeScript

// frontend/src/components/permissions.ts
import type { User } from './types'
export function hasRight(user: User | null | undefined, right: string) {
if (!user) {
return false
}
return user.rights?.includes('admin') || user.rights?.includes(right)
}
export function hasAnyRight(user: User | null | undefined, rights: string[]) {
return rights.some((right) => hasRight(user, right))
}