feat: add join form
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Simon 2026-03-10 18:25:17 +01:00
parent eadf90b5fc
commit f1d0526209
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
19 changed files with 547 additions and 15 deletions

View file

@ -80,7 +80,7 @@ defmodule MvWeb.Plugs.CheckPagePermission do
Used by LiveView hook to skip redirect on sign-in etc.
"""
def public_path?(path) when is_binary(path) do
path in ["/register", "/reset", "/set_locale", "/sign-in", "/sign-out"] or
path in ["/register", "/reset", "/set_locale", "/sign-in", "/sign-out", "/join"] or
String.starts_with?(path, "/auth") or
String.starts_with?(path, "/confirm") or
String.starts_with?(path, "/password-reset")

View file

@ -0,0 +1,33 @@
defmodule MvWeb.Plugs.JoinFormEnabled do
@moduledoc """
For GET /join: returns 404 when the join form is disabled in settings.
No-op for other paths.
"""
import Plug.Conn
alias Mv.Membership
def init(opts), do: opts
def call(conn, _opts) do
if join_path?(conn), do: maybe_404(conn), else: conn
end
defp join_path?(conn) do
conn.request_path == "/join" and conn.method == "GET"
end
defp maybe_404(conn) do
case Membership.get_settings() do
{:ok, %{join_form_enabled: true}} -> conn
_ -> send_404(conn)
end
end
defp send_404(conn) do
conn
|> put_resp_content_type("text/html")
|> send_resp(404, "Not Found")
|> halt()
end
end