ash_authentication/dev/dev_server/clear_session.ex
James Harton 8797005175
feat(Ash.PlugHelpers): Support standard actor configuration. (#16)
* 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.
2022-10-31 16:43:00 +13:00

23 lines
464 B
Elixir

defmodule DevServer.ClearSession do
@moduledoc """
Resets the session storage, to 'log out" all users.
"""
@behaviour Plug
alias Plug.Conn
@doc false
@impl true
@spec init(keyword) :: keyword
def init(opts), do: opts
@doc false
@impl true
@spec call(Conn.t(), any) :: Conn.t()
def call(conn, _opts) do
conn
|> Conn.clear_session()
|> Conn.put_resp_header("location", "/")
|> Conn.send_resp(302, "Redirected")
end
end