# `Permit.Phoenix.LiveView.AuthorizeHook`
[🔗](https://github.com/curiosum-dev/permit_phoenix/blob/v0.5.1/lib/permit_phoenix/live_view/authorize_hook.ex#L1)

Hooks into the :mount and :handle_params lifecycles to authorize the current action.
The current action is denoted by the :live_action assign (retrieved from the router),
for example with the following route definition:

    live "/organizations", OrganizationLive.Index, :index

the :live_action assign value will be :index.

## Configuration

Add this module to the :on_mount option of the live_session in your router.

```
live_session :require_authenticated_user, on_mount: [
    {BlogWeb.UserAuth, :ensure_authenticated}, # authentication generated by mix phx.gen.auth
    Permit.Phoenix.LiveView.AuthorizeHook      # Permit.Phoenix's hook at mount
  ] do
  # Your live routes with named :live_action names
end
```

## Usage

See `Permit.Phoenix.LiveView` for detailed information on authorizing LiveView navigation and events.

---

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