ash_authentication_phoenix/dev/dev_web/controllers/auth_controller.ex
Zach Daniel 903f3a386e
feat: support new sign in tokens feature on password strategy (#176)
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>
2023-04-06 15:59:52 +12:00

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