# `PhoenixKitAgent.Web.Access`
[🔗](https://github.com/BeamLabEU/phoenix_kit_agent/blob/v0.1.0/lib/phoenix_kit_agent/web/access.ex#L1)

The permission checks of the module's admin pages, made again on every event.

A LiveView keeps the scope it got at mount, so a role taken away while the
page is open, a switch to another role or a logout would still read as the
rights of the mount. Each check here asks for two scopes and passes only if
both hold:

  * the socket's (`:phoenix_kit_current_scope`, set by core's `on_mount`);
  * the scope of the **session** as it is now
    (`PhoenixKit.Users.Auth.SessionRef.scope_for_session/2`): the session
    must still be live, its user active and confirmed, and the scope is
    narrowed to the role the session acts as — not the user's default role.

The page calls `assign_session/2` in its `mount/3`. The session reference is
read from the signed session only in the connected mount; the static render
has none and is checked against the socket's scope alone, which core's
`on_mount` has just built from this session. A connected page without a
live session is refused everything.

# `assign_session`

```elixir
@spec assign_session(Phoenix.LiveView.Socket.t(), map()) ::
  Phoenix.LiveView.Socket.t()
```

Keeps the reference of the session the page runs in (see the moduledoc):
read from `session` in the connected mount, `nil` in the static render.

# `may_manage?`

```elixir
@spec may_manage?(Phoenix.LiveView.Socket.t()) :: boolean()
```

Whether the signed-in session holds `agent.manage` now (see the moduledoc).

# `owner?`

```elixir
@spec owner?(Phoenix.LiveView.Socket.t()) :: boolean()
```

Whether the signed-in session is an Owner's now (see the moduledoc).

# `session_scope`

```elixir
@spec session_scope(Phoenix.LiveView.Socket.t()) ::
  PhoenixKit.Users.Auth.Scope.t() | nil
```

The scope of the session as it is now (`nil` if it can no longer act, see
the moduledoc): what a context function that checks a permission itself is
given.

# `user_uuid`

```elixir
@spec user_uuid(Phoenix.LiveView.Socket.t()) :: String.t() | nil
```

The uuid of the signed-in user, or `nil`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
