@doc """ Logs in a user with `AshAuthentication` as the current user. """ def log_in_user_as_subject(conn, user) do conn |> Phoenix.ConnTest.init_test_session(%{}) |> AshAuthentication.Phoenix.Plug.store_in_session(user) |> Plug.Conn.assign(:current_user, user) end
@doc """ Logs in a user with `AshAuthentication` as the current user. """ def log_in_user_as_subject(conn, user) do conn |> Phoenix.ConnTest.init_test_session(%{}) |> AshAuthentication.Phoenix.Plug.store_in_session(user) |> Plug.Conn.assign(:current_user, user) end
** (KeyError) key :token not found in: %{} code: conn = log_in_user_as_subject(conn, user) stacktrace: (ash_authentication 4.9.2) lib/ash_authentication/plug/helpers.ex:18: AshAuthentication.Plug.Helpers.store_in_session/2
** (KeyError) key :token not found in: %{} code: conn = log_in_user_as_subject(conn, user) stacktrace: (ash_authentication 4.9.2) lib/ash_authentication/plug/helpers.ex:18: AshAuthentication.Plug.Helpers.store_in_session/2
Looks like it's because I'm creating users for test using
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.