Add configurable prevention of user registration

Should be done appropriately soon.
This commit is contained in:
Thelonius Kort
2023-01-31 18:16:28 +01:00
parent 54b609185d
commit c5853fc2aa
4 changed files with 29 additions and 4 deletions

View File

@ -0,0 +1,20 @@
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