mirror of
https://github.com/team-alembic/ash_authentication_phoenix.git
synced 2024-09-20 05:23:55 +12:00
7c90908ad9
* 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>
32 lines
634 B
Elixir
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
|