15 lines
400 B
TypeScript
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))
|
|
} |