Sigra.Plug.LoadOrganizationFromSlug (Sigra v1.20.0)

Copy Markdown View Source

URL-driven active organization loader (Phase 16 D-03, D-04, D-13).

Reads conn.params[scope_param] (default "org"), resolves the organization by slug, verifies membership, follows 7-day slug aliases, and refreshes the session pointer when the URL org differs from the session pointer — delegating the write to Sigra.Plug.PutActiveOrganization.call/3 (Phase 14 D-16 single-writer).

Returns 404 via the configured error_handler for unknown slugs AND for known slugs the current user is not a member of (enumeration prevention, D-04). Both paths go through the same :not_found disposition so callers cannot distinguish them by response shape or timing.

Options

  • :error_handler — required. Module implementing Sigra.Plug.ErrorHandler. Used for the :not_found halt path.
  • :organizations — required. The host's use Sigra.Organizations module exposing __sigra_org_config__/0.
  • :session_store — required. Module implementing Sigra.SessionStore. Forwarded to Sigra.Plug.PutActiveOrganization.call/3 when the URL org differs from the session pointer.
  • :scope_module — required. Host scope module for put_active_organization/3.
  • :scope_param — optional. URL param name holding the slug. Default: "org".
  • :session_store_opts — optional. Forwarded to the session store.