ash_authentication_phoenix/test/support/auth_controller.ex
Andrew Hacking 7c90908ad9
test: dynamic router - some additional tests, fixes and failures (#493)
* test: Scoped router tests

* test: Initial controller tests

* docs: Router helper docs, including :unscoped

* chore: Code formatting

* fix: ensure path params are processed on strategy router

* test: Working controller tests for register, sign-in, sign-out

---------

Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-08-14 11:48:18 -04:00

32 lines
634 B
Elixir

defmodule AshAuthentication.Phoenix.Test.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)
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(:signed_out)
end
end