ash_authentication_phoenix/dev/dev_web/controllers/auth_controller.ex

33 lines
620 B
Elixir
Raw Normal View History

2022-10-25 11:23:05 +13:00
defmodule DevWeb.AuthController do
@moduledoc false
use DevWeb, :controller
use AshAuthentication.Phoenix.Controller
2022-10-25 11:23:05 +13:00
@doc false
@impl true
def success(conn, _activity, user, _token) do
2022-10-25 11:23:05 +13:00
conn
|> store_in_session(user)
2022-10-25 11:23:05 +13:00
|> assign(:current_user, user)
|> put_status(200)
|> render("success.html")
end
@doc false
@impl true
def failure(conn, _activity, reason) do
2022-10-25 11:23:05 +13:00
conn
|> assign(:failure_reason, reason)
|> redirect(to: "/sign-in")
2022-10-25 11:23:05 +13:00
end
@doc false
@impl true
def sign_out(conn, _params) do
conn
|> clear_session()
|> render("sign_out.html")
end
end