UNPKG

@adonis-agora/authz-react

Version:

React/Inertia bindings for @adonis-agora/authz: AuthzProvider, useAuthz, useCan, <Can>, and a server-side buildAuthzShare() for the Inertia share.

17 lines • 771 B
/** * Monta o share de autorização a partir do `AuthzService` para um usuário. * Roda no servidor (o host chama no seu middleware Inertia). Usa * `effectiveRoles`/`effectivePermissions` (store ∪ roleGrants ∪ resolveRoles * ∪ contexto) — as MESMAS que `can()` usa — para o gating de UI casar com a * decisão de servidor. `null`/`undefined` (anônimo) devolve o share vazio. */ export async function buildAuthzShare(authz, user, scope) { if (user === null || user === undefined) return { roles: [], permissions: [] }; const [roles, permissions] = await Promise.all([ authz.effectiveRoles(user, scope), authz.effectivePermissions(user, scope), ]); return { roles, permissions }; } //# sourceMappingURL=share.js.map