Sigra.Admin.Scope (Sigra v1.20.0)

Copy Markdown View Source

Request-local resolved admin scope derived from the host's current scope.

/admin and /admin/organizations/:org are distinct authorization paths. This module resolves that route-owned intent into an explicit struct that downstream plugs, LiveViews, queries, and mutations can share.

Summary

Types

error_reason()

@type error_reason() :: :unauthenticated | :forbidden | :not_found

mode()

@type mode() :: :global | :organization

t()

@type t() :: %Sigra.Admin.Scope{
  admin_org_ids: [term()],
  mode: mode(),
  organization: map() | nil,
  organization_id: term() | nil,
  organization_slug: String.t() | nil,
  platform_admin?: boolean(),
  scope: term()
}

Functions

global?(scope)

@spec global?(t()) :: boolean()

organization?(scope)

@spec organization?(t()) :: boolean()

resolve(scope, requested_org, policy_module)

@spec resolve(term(), nil | binary() | map(), module()) ::
  {:ok, t()} | {:error, error_reason()}