Files
phoenix-ausblick/lib/outlook_web/prevent_registration.ex
Thelonius Kort c5853fc2aa Add configurable prevention of user registration
Should be done appropriately soon.
2023-01-31 18:16:28 +01:00

21 lines
466 B
Elixir

defmodule Outlook.PreventRegistration do
import Plug.Conn
import Phoenix.Controller
def prevent_registration(conn, _) do
if System.get_env("DISABLE_REGISTRATION") && is_registration_path(conn) do
conn
|> put_flash(:error, "User Registration is disabled.")
|> redirect(to: "/users/log_in")
|> halt()
else
conn
end
end
defp is_registration_path(conn) do
"/users/register" == current_path(conn, %{})
end
end