2019-11-15 03:40:35 +01:00
|
|
|
defmodule PowLockout.Phoenix.UnlockController do
|
|
|
|
@moduledoc false
|
|
|
|
use Pow.Extension.Phoenix.Controller.Base
|
|
|
|
|
|
|
|
alias Plug.Conn
|
|
|
|
alias PowLockout.Plug
|
|
|
|
|
|
|
|
@spec process_show(Conn.t(), map()) :: {:ok | :error, map(), Conn.t()}
|
|
|
|
def process_show(conn, %{"id" => token}), do: Plug.unlock_account(conn, token)
|
|
|
|
|
|
|
|
@spec respond_show({:ok | :error, map(), Conn.t()}) :: Conn.t()
|
|
|
|
def respond_show({:ok, _user, conn}) do
|
|
|
|
conn
|
|
|
|
|> put_flash(:info, extension_messages(conn).account_has_been_unlocked(conn))
|
|
|
|
|> redirect(to: routes(conn).session_path(conn, :new))
|
|
|
|
end
|
2020-01-11 05:20:19 +01:00
|
|
|
|
2019-11-15 03:40:35 +01:00
|
|
|
def respond_show({:error, _changeset, conn}) do
|
|
|
|
conn
|
|
|
|
|> put_flash(:error, extension_messages(conn).account_unlock_failed(conn))
|
|
|
|
|> redirect(to: routes(conn).session_path(conn, :new))
|
|
|
|
end
|
|
|
|
end
|