templates2.Content.Next/lib/rbac.ts
w4c-templates 3caefb8833
Some checks are pending
CI / quality (push) Waiting to run
chore(template): publish Content.Next
2026-10-11 23:29:57 +03:00

21 lines
685 B
TypeScript

export type ContentRole = 'admin' | 'editor' | 'user';
export const CONTENT_ROLES: ContentRole[] = ['admin', 'editor', 'user'];
export function isContentRole(value: unknown): value is ContentRole {
return value === 'admin' || value === 'editor' || value === 'user';
}
/** Admins and editors may author content; plain users are read-only. */
export function canAuthor(role: unknown): boolean {
return role === 'admin' || role === 'editor';
}
/** Only admins manage users, roles and the audit log. */
export function isAdmin(role: unknown): boolean {
return role === 'admin';
}
export function roleLabel(role: unknown): string {
return isContentRole(role) ? role : 'user';
}