Wiztchta.Plug (wiztchta v0.1.0)

Copy Markdown View Source

Verifies the submitted challenge and stores the result in conn.assigns.wiztchta as :ok or {:error, reason}.

The plug never halts; your action decides what to do:

plug Wiztchta.Plug when action in [:create]

def create(conn, params) do
  case conn.assigns.wiztchta do
    :ok -> ...
    {:error, reason} ->
      conn
      |> put_flash(:error, Wiztchta.error_message(reason))
      |> render(:new, ...)
  end
end

Options are forwarded to Wiztchta.verify/2.