AshAuthentication.Phoenix.LiveSession.RequireRecoveryCodes
(ash_authentication_phoenix v3.0.0-rc.6)
View Source
A LiveView on_mount hook that enforces recovery code configuration.
This module provides an on_mount hook that checks if the current user has recovery codes configured and redirects to the setup page if not.
Behaviour When No User Is Present
When there is no authenticated user, this hook returns {:cont, socket}
without modification. Use this hook after your authentication hook.
Usage
live_session :require_recovery_codes,
on_mount: [
{AshAuthentication.Phoenix.LiveSession, :default},
{AshAuthentication.Phoenix.LiveSession.RequireRecoveryCodes, :require_recovery_codes}
] do
live "/secure", SecureLive
endOptions
:current_user_assign- The assign key for the current user. Defaults to:current_user.:setup_path- Path to redirect to. Defaults to"/recovery-codes".:error_message- Flash message when redirecting. Defaults to"Recovery codes required".:strategy- The name of the recovery code strategy.
Summary
Functions
LiveView on_mount callback that requires recovery code configuration.
Returns true if the current user has recovery codes configured.
Checks if the current user has recovery codes configured and redirects if not.
Functions
LiveView on_mount callback that requires recovery code configuration.
@spec recovery_codes_configured?( Phoenix.LiveView.Socket.t(), keyword() ) :: boolean()
Returns true if the current user has recovery codes configured.
@spec require_recovery_codes( Phoenix.LiveView.Socket.t(), keyword() ) :: {:cont, Phoenix.LiveView.Socket.t()} | {:halt, Phoenix.LiveView.Socket.t()}
Checks if the current user has recovery codes configured and redirects if not.
Returns {:cont, socket} if configured, or {:halt, socket} with a redirect if not.