mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-20 21:33:10 +12:00
8797005175
* improvement(docs): change all references to `actor` to `user`. The word "actor" has special meaning in the Ash ecosystem. * chore: format `dev` directory also. * feat(Ash.PlugHelpers): Support standard actor configuration. * Adds the `:set_actor` plug which will set the actor to a resource based on the subject name. * Also includes GraphQL and JSON:API interfaces in the devserver for testing.
37 lines
887 B
Elixir
37 lines
887 B
Elixir
defmodule DevServer.TestPage do
|
|
@moduledoc """
|
|
Displays a very basic login form according to the currently configured
|
|
Überauth providers.
|
|
"""
|
|
@behaviour Plug
|
|
alias Plug.Conn
|
|
require EEx
|
|
|
|
EEx.function_from_file(:defp, :render, String.replace(__ENV__.file, ".ex", ".html.eex"), [
|
|
:assigns
|
|
])
|
|
|
|
@doc false
|
|
@impl true
|
|
@spec init(keyword) :: keyword
|
|
def init(opts), do: opts
|
|
|
|
@doc false
|
|
@spec call(Conn.t(), any) :: Conn.t()
|
|
@impl true
|
|
def call(conn, _opts) do
|
|
resources = AshAuthentication.authenticated_resources(:ash_authentication)
|
|
|
|
current_users =
|
|
conn.assigns
|
|
|> Stream.filter(fn {key, _value} ->
|
|
key
|
|
|> to_string()
|
|
|> String.starts_with?("current_")
|
|
end)
|
|
|> Map.new()
|
|
|
|
payload = render(resources: resources, current_users: current_users)
|
|
Conn.send_resp(conn, 200, payload)
|
|
end
|
|
end
|