Checks an authenticated caller's permissions. Routes call it where the answer depends on more than the permission, such as "the owner, or a moderator"; requirePermission gates a whole route instead.

Functions

f
can(
payload: AuthPayload,
permission: Permission
): boolean

Checks whether the caller's role grants permission. The role is the live one authenticate put in the payload, not the token's.

Usage

import * as mod from "api/lib/permissions.ts";