14 lines
399 B
TypeScript
14 lines
399 B
TypeScript
/**
|
|
* Permission checks against an authenticated caller.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
import { hasPermission, type Permission } from "../../shared/permissions.ts";
|
|
import type { AuthPayload } from "../model/auth.ts";
|
|
|
|
/** Checks whether the caller's role grants `permission`. */
|
|
export function can(payload: AuthPayload, permission: Permission): boolean {
|
|
return hasPermission(payload.role, permission);
|
|
}
|