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

@ -0,0 +1,27 @@
defmodule Mv.Accounts.User.Validations.RegistrationEnabled do
@moduledoc """
Validation that blocks direct registration (register_with_password) when
registration is disabled in global settings. Used so that even direct API/form
submissions cannot register when the setting is off.
"""
use Ash.Resource.Validation
alias Mv.Membership
@impl true
def init(opts), do: {:ok, opts}
@impl true
def validate(_changeset, _opts, _context) do
case Membership.get_settings() do
{:ok, %{registration_enabled: true}} ->
:ok
_ ->
{:error,
field: :base,
message:
"Registration is disabled. Please use the join form or contact an administrator."}
end
end
end