Skip to main content

access_context

Function access_context 

Source
pub async fn access_context(pool: &Pool, viewer: Option<&User>) -> AccessContext
Expand description

Build the per-render AccessContext for viewer: load every tenant restriction (+ the restricted pages’ paths) and per-type restriction, and resolve the viewer’s codenames + role ids. Bounded, fixed number of queries; the viewer lookups are skipped entirely when nothing is gated or the viewer is a superuser.

When the restrictions can’t be read the context hides every page from everyone but superusers: a menu or search result must not list a gated page’s title and URL because the lookup failed.