feat: allow disabling registration
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Simon 2026-03-13 16:40:39 +01:00
parent eb18209669
commit 09e4b64663
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
14 changed files with 344 additions and 5 deletions

View file

@ -4,6 +4,8 @@ defmodule MvWeb.AuthControllerTest do
import Phoenix.ConnTest
import ExUnit.CaptureLog
alias Mv.Membership
# Helper to create an unauthenticated conn (preserves sandbox metadata)
defp build_unauthenticated_conn(authenticated_conn) do
# Create new conn but preserve sandbox metadata for database access
@ -169,6 +171,23 @@ defmodule MvWeb.AuthControllerTest do
assert html =~ "length must be greater than or equal to 8"
end
test "when registration is disabled, sign-in page does not show Need an account? toggle", %{
conn: authenticated_conn
} do
{:ok, settings} = Membership.get_settings()
original = Map.get(settings, :registration_enabled, true)
{:ok, _} = Membership.update_settings(settings, %{registration_enabled: false})
try do
conn = build_unauthenticated_conn(authenticated_conn)
{:ok, _view, html} = live(conn, ~p"/sign-in")
refute html =~ "Need an account?"
after
{:ok, s} = Membership.get_settings()
Membership.update_settings(s, %{registration_enabled: original})
end
end
# Access control
test "unauthenticated user accessing protected route gets redirected to sign-in", %{
conn: authenticated_conn