mirror of
https://github.com/team-alembic/ash_authentication_phoenix.git
synced 2024-09-20 13:34:26 +12:00
903f3a386e
As of version `3.10.5` `ash_authentication` now supports generating and validating short-lived sign in tokens as part of the password sign in flow. This feature seamlessly enables this flow simply by turning on `sign_in_tokens_enabled?` in the password strategy DSL. --------- Co-authored-by: James Harton <james@harton.nz>
32 lines
620 B
Elixir
32 lines
620 B
Elixir
defmodule DevWeb.AuthController do
|
|
@moduledoc false
|
|
|
|
use DevWeb, :controller
|
|
use AshAuthentication.Phoenix.Controller
|
|
|
|
@doc false
|
|
@impl true
|
|
def success(conn, _activity, user, _token) do
|
|
conn
|
|
|> store_in_session(user)
|
|
|> assign(:current_user, user)
|
|
|> put_status(200)
|
|
|> render("success.html")
|
|
end
|
|
|
|
@doc false
|
|
@impl true
|
|
def failure(conn, _activity, reason) do
|
|
conn
|
|
|> assign(:failure_reason, reason)
|
|
|> redirect(to: "/sign-in")
|
|
end
|
|
|
|
@doc false
|
|
@impl true
|
|
def sign_out(conn, _params) do
|
|
conn
|
|
|> clear_session()
|
|
|> render("sign_out.html")
|
|
end
|
|
end
|