ash_authentication_phoenix/dev/dev_web/controllers/auth_controller.ex

33 lines
641 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)
|> put_status(401)
|> render("failure.html")
end
@doc false
@impl true
def sign_out(conn, _params) do
conn
|> clear_session()
|> render("sign_out.html")
end
end