Gate self-serve registration behind ENABLE_ACCOUNT_REGISTRATION (#25)
Unit Tests / test (push) Successful in 9s

## Summary
- Add `ENABLE_ACCOUNT_REGISTRATION` (default `false`) for self-serve sign-up, set via env / control-node secret (`chat_backend_<env>.env`)
- Harden `POST /api/user/create/` to create company + user, return JWTs, and reject when the flag is off
- Expose `GET /api/public/settings/` with `enable_account_registration` for the SPA

Supports frontend: [chat_web_app#31](ai_ml_operations/chat_web_app#31)

## Test plan
- [ ] `cd llm_be && uv run python manage.py test chat_backend.tests.test_views_users`
- [ ] Confirm `POST /api/user/create/` returns 403 when flag unset/false
- [ ] With `ENABLE_ACCOUNT_REGISTRATION=true`, register returns access/refresh + creates company
- [ ] `GET /api/public/settings/` returns the flag
- [ ] Add `ENABLE_ACCOUNT_REGISTRATION=false` to control-node `chat_backend_prod.env` / `chat_backend_beta.env` before deploy (see `.env.prod.example`)Reviewed-on: #25
This commit was merged in pull request #25.
This commit is contained in:
2026-07-27 04:19:59 -07:00
parent ad44359804
commit 30ce3d048d
8 changed files with 160 additions and 15 deletions
+4
View File
@@ -45,6 +45,10 @@ EMAIL_USE_TLS=true
# Captcha
CAPTCHA_SECRET_KEY=replace-with-captcha-secret
# Self-serve account registration (sign-up). Keep false until ready to open
# public registration; set true in chat_backend_prod.env / chat_backend_beta.env.
ENABLE_ACCOUNT_REGISTRATION=false
# Stripe / finance
STRIPE_SECRET_KEY=replace-with-stripe-secret-key
STRIPE_PUBLISHABLE_KEY=replace-with-stripe-publishable-key