canAccessAdminPanel
canAccessAdminPanel(
props):boolean
Defined in: packages/core/src/access/canAccessAdminPanel.ts:56
Answers whether a caller may open the admin panel at all — the
adminPanel.access gate.
This is the coarse entry check. It is deliberately separate from the per-collection checks: a caller who fails this should never reach the panel, whereas a caller who passes it may still be denied individual collections.
Call it in the host app’s admin route (a server component, layout, or
middleware) and redirect on false. It never throws: the adminPanel.access
subject carries no document, so it is evaluated with
scope: "any" — a permission callback that only reads user/organization
resolves normally, and one that reaches for a document resolves to true
rather than throwing, since “can this caller use the panel” is inherently a
subject-level question.
Prefer this over hand-writing hasPermission({ resource: "adminPanel", … })
so the subject key and action are never spelled by hand.
Parameters
Section titled “Parameters”The access config plus the resolved caller.
Returns
Section titled “Returns”boolean
true when the caller may open the admin panel; false to deny.
Also true when access is undefined (RBAC not configured).
Example
Section titled “Example”const auth = await fetchAuthQuery(api.auth.api.getUserOrg, {});if (!canAccessAdminPanel({ access, user: auth.user, organization: auth.organization })) { redirect("/unauthorized");}hasPermission for the general check this delegates to