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
+3
View File
@@ -25,6 +25,9 @@ EMAIL_USE_TLS=true
# Captcha (optional local)
CAPTCHA_SECRET_KEY=
# Self-serve sign-up (default false — set true to allow /user/create/)
ENABLE_ACCOUNT_REGISTRATION=false
# Stripe / finance (optional local — required for checkout + webhooks)
STRIPE_SECRET_KEY=
STRIPE_PUBLISHABLE_KEY=