IngotWeb.Live.AuthHooks (Ingot v0.1.0)
View SourceLiveView on_mount hooks for authentication and authorization.
Provides hooks that can be used in LiveView modules to require authentication and check permissions.
Usage
defmodule MyAppWeb.SomeLive do
use MyAppWeb, :live_view
# Require authentication
on_mount {IngotWeb.Live.AuthHooks, :require_authenticated_user}
# Require specific role
on_mount {IngotWeb.Live.AuthHooks, {:require_role, :admin}}
# Check queue access
on_mount {IngotWeb.Live.AuthHooks, {:require_queue_access, "queue_id"}}
endAssigns
The following assigns are set by these hooks:
:current_user- Map containing user_id, email, and roles (set by :require_authenticated_user)
Summary
Functions
on_mount hook for authentication and authorization.
Functions
on_mount hook for authentication and authorization.
Supports multiple hooks:
:require_authenticated_user- Validates session and assigns current_user{:require_role, role}- Checks that user has specific role{:require_queue_access, queue_id}- Verifies user has access to queue