Skip to main content

with_cms_admin_access

Function with_cms_admin_access 

Source
pub fn with_cms_admin_access(
    router: Router,
    no_access_url: impl Into<String>,
) -> Router
Expand description

Gate the CMS-admin router on the cms_admin.access codename.

A logged-in tenant user is allowed through only when:

  1. they’re a superuser, OR
  2. one of their roles grants the cms_admin.access codename.

Otherwise the request is redirected to no_access_url (defaults to /cms-admin/no-access) so the user gets a friendly “you’re signed in but not allowed here” page instead of an empty 403.

Tri-dialect. Resolves the user via the framework’s SessionUser extractor. Anonymous requests pass through unchanged — pair this with with_login_required above so that hits the login flow first.