ash_hq/lib/ash_hq_web/live_user_auth.ex
Zach Daniel 025b56d1a4 improvement: get a build set up
improvement: fix lint/security issues
improvement: add CSP
improvement: remove currently unnecessary/old code
2022-08-06 19:22:58 -04:00

17 lines
400 B
Elixir

defmodule AshHqWeb.LiveUserAuth do
@moduledoc """
Helpers for authenticating users in liveviews
"""
@doc """
Sets the current user on each mount of a liveview
"""
def on_mount(:live_user, _params, session, socket) do
{:cont,
Phoenix.LiveView.assign(
socket,
:current_user,
AshHqWeb.UserAuth.user_for_session_token(session["user_token"])
)}
end
end