View Source AshAuthentication.Phoenix.LiveSession (ash_authentication_phoenix v1.4.3)
Ensures that any loaded users which are present in a conn's assigns are also present in a live view socket's assigns.
Typical usage is via the ash_authentication_live_session/2
macro, but can also
manually called like so:
scope "/", ExampleWeb do
pipe_through(:browser)
live_session :authenticated, on_mount: LiveSession, session: {LiveSession, :session, []} do
live "/", ExampleLive
end
end
Link to this section Summary
Functions
Generate a live session wherein all subject assigns are copied from the conn into the socket.
Supplements the session with any current_X
assigns which are authenticated
resource records from the conn.
Inspects the incoming session for any subject_name -> subject values and loads them into the socket's assigns.
Link to this section Functions
ash_authentication_live_session(session_name \\ :ash_authentication, list)
View Source (macro)Generate a live session wherein all subject assigns are copied from the conn into the socket.
@spec generate_session(Plug.Conn.t()) :: %{required(String.t()) => String.t()}
Supplements the session with any current_X
assigns which are authenticated
resource records from the conn.
@spec on_mount( atom(), %{required(String.t()) => any()}, %{required(String.t()) => any()}, Phoenix.LiveView.Socket.t() ) :: {:cont | :halt, Phoenix.LiveView.Socket.t()}
Inspects the incoming session for any subject_name -> subject values and loads them into the socket's assigns.
For example a session containing {"user", "user?id=aa6c179c-ee75-4d49-8796-528c2981b396"}
becomes an assign called
current_user
with the loaded user as the value.