Files
refboard-ayon/.env.example
T
Hiren Kangad 2fb71b4ae1 feat: runtime self-registration toggle in admin dashboard
Self-registration is now controlled at runtime from the admin panel rather
than at build time via an env var. Default: off.

- New `settings` table (key/value/updated_at) plus getSetting/setSetting
  helpers. Idempotent first-boot migration seeds allow_self_registration
  from the ALLOW_SELF_REGISTRATION env var; after first boot the env var
  is ignored and admins control the toggle from the UI.
- New public GET /api/auth/config (no auth) — returns
  { allowSelfRegistration, hasUsers }. The Login page polls this on mount
  to decide whether to show a Register link, and to render
  "Create the first admin account" mode when the install is empty.
- New admin GET /api/admin/settings + PUT /api/admin/settings/:key for
  the dashboard. Constrained to a known-keys allowlist with type coercion
  so unrecognized keys can't be stored.
- POST /api/auth/register now reads the toggle from the database instead
  of process.env. The first user is still always allowed and is auto-
  promoted to admin.
- Admin.tsx grows a "Settings" card with a labelled toggle switch and
  toast feedback. The card sits above the user table.
- VITE_ALLOW_SELF_REGISTRATION dropped — runtime fetch replaces it.

Docs: README + .env.example clarify that ALLOW_SELF_REGISTRATION is now
an initial seed only, the going-public checklist points at the dashboard
toggle, and the features list calls out runtime control.
2026-04-28 20:56:52 +05:30

56 lines
2.0 KiB
Bash

# ────────────────────────────────────────────────
# RefBoard — Environment Configuration
# Copy this file to `.env` and edit values for your install.
# ────────────────────────────────────────────────
# ---- Server ----
PORT=8000
NODE_ENV=development
CORS_ORIGIN=*
# ---- JWT auth ----
# REQUIRED in production. Generate with: openssl rand -base64 64
JWT_SECRET=change-me-to-a-long-random-string
JWT_EXPIRES_IN=7d
# ---- SQLite database ----
# Path inside the running process. Defaults to /app/data/refboard.db (Docker).
# For local non-Docker dev, set this to ./data/refboard.db (relative to backend/).
DB_PATH=/app/data/refboard.db
# ---- Object storage (MinIO / any S3-compatible) ----
MINIO_ENDPOINT=minio
MINIO_PORT=9000
MINIO_USE_SSL=false
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=refboard
# Public-facing base URL for media. Leave empty to serve via the backend proxy
# (recommended for self-hosted single-box installs).
PUBLIC_URL=
# Max upload size in MB (per file). Defaults to 200.
MAX_FILE_SIZE_MB=200
# ---- First-run admin bootstrap ----
# When the server starts and no user with this email exists, RefBoard will
# create one with role=admin. Idempotent — runs every boot but only seeds once.
# Leave blank to skip seeding.
SEED_ADMIN_EMAIL=
SEED_ADMIN_PASSWORD=
SEED_ADMIN_USERNAME=
SEED_ADMIN_DISPLAY_NAME=
# ---- Self-registration ----
# Initial value for the runtime self-registration toggle. Default "false".
# After the first boot this env var is IGNORED — admins control the toggle
# from the dashboard at /admin (it's persisted in the database).
# The very first user can always register, regardless of this flag, and is
# auto-promoted to admin.
ALLOW_SELF_REGISTRATION=false
# ---- Optional: API key for bot / programmatic upload ----
# If set, /api/upload/api-key endpoints require this header value.
REFBOARD_API_KEY=