mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-04 00:42:14 +00:00
feat: add default-off switch for email domain registration quota
PR #5423 relaxed the email suffix whitelist: once a whitelist is configured, non-whitelisted registrable domains are each allowed to register one account. That behavior activated unconditionally. Add registration_email_domain_quota_enabled (default false) to gate it: - Off (default): restore pre-#5423 strict whitelist semantics — with a non-empty whitelist, non-whitelisted domains are rejected with EMAIL_SUFFIX_NOT_ALLOWED; the register/verify views restore the client-side whitelist pre-check and allowed-domain hint. - On: keep #5423 behavior — one account per non-whitelisted registrable domain (EMAIL_DOMAIN_REGISTRATION_LIMIT). - Empty whitelist keeps allowing all domains in both states. Gating lives in validateRegistrationEmailQuota and (as a race-safety backstop) createUserWithRegistrationEmailGuard; the repository-level domain lock + in-tx recheck is unchanged. The admin update field is *bool (omitted = keep current) so stale full-payload saves cannot silently flip the switch. Email binding and OAuth auto-signup keep their strict policy, and pending-OAuth bind-login for existing accounts is unaffected because the handler resolves existing emails before the quota check. Frontend adds the toggle to admin settings (zh/en copy; whitelist hint restored to strict wording, quota wording moved to the new toggle) and exposes the flag via public settings + SSR injection payload. Tests: #5423 quota tests now enable the switch explicitly; new default-off regression tests cover register/send-code/async/pending OAuth/OIDC create-account plus both register views; API contract JSON and the injection drift guard are updated.
This commit is contained in:
1 parent
f2da30bcd9
commit
563a72ca73
27 files changed
+836
-444
No files matched your search
@@ -392,6 +392,7 @@ export interface SystemSettings {
|
||||
registration_enabled: boolean;
|
||||
email_verify_enabled: boolean;
|
||||
registration_email_suffix_whitelist: string[];
|
||||
registration_email_domain_quota_enabled: boolean;
|
||||
promo_code_enabled: boolean;
|
||||
password_reset_enabled: boolean;
|
||||
frontend_url: string;
|
||||
@@ -734,6 +735,7 @@ export interface UpdateSettingsRequest {
|
||||
registration_enabled?: boolean;
|
||||
email_verify_enabled?: boolean;
|
||||
registration_email_suffix_whitelist?: string[];
|
||||
registration_email_domain_quota_enabled?: boolean;
|
||||
promo_code_enabled?: boolean;
|
||||
password_reset_enabled?: boolean;
|
||||
frontend_url?: string;
|
||||
|
||||
Reference in new issue
Block a user