Files
linkvault/app/config.py
Erik Thiele 604c4ea9c2 Add invite-code registration and admin user management
Open registration let anyone with the URL create an account. Two
changes address that:

- REGISTRATION_CODE (.env, optional): when set, registration requires
  entering it correctly. Empty/unset keeps registration open, so
  existing installs are unaffected until configured.
- is_admin flag on User: the first account ever created on an install
  becomes admin automatically (existing installs get their oldest
  account promoted via the startup migration, so nobody is locked
  out of user management after upgrading).

Admins get a new "Benutzerverwaltung" panel in Einstellungen listing
every account (email, link/prompt counts, join date) with a delete
button per account — deleting cascades to that user's links and
prompts via the existing relationship cascade. Deleting your own
account through this page is blocked (redirects with an error) to
avoid accidental admin lockout. Non-admins get a 403 on the
/settings/users routes.

Also fixes several pre-existing German pluralization bugs found while
writing the new counts ("2 Linke" -> "2 Links", "Kontoen"/"Konton" ->
"Konten") — irregular plurals need a full word swap, not a suffix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 11:16:01 +02:00

25 lines
873 B
Python

import os
import socket
from dotenv import load_dotenv
load_dotenv()
APP_AUTHOR = "Erik Thiele"
APP_VERSION = os.getenv("APP_VERSION", "2.1.0")
APP_HOST = socket.gethostname()
SECRET_KEY = os.getenv("SECRET_KEY", "dev-insecure-secret-change-me")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "").strip()
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o-mini")
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL", "text-embedding-3-small")
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./linkvault.db")
# KI-Funktionen (Kategorisierung, Zusammenfassung, semantische Suche)
# sind nur aktiv, wenn ein API-Key hinterlegt ist.
AI_ENABLED = bool(OPENAI_API_KEY)
# Ist ein Code gesetzt, muss er bei der Registrierung korrekt eingegeben
# werden. Leer = Registrierung bleibt für alle offen (Standardverhalten).
REGISTRATION_CODE = os.getenv("REGISTRATION_CODE", "").strip()