feat: update application version to 0.8.20 and enhance superadmin role management
- Bumped application version to 0.8.20 in both backend and frontend files. - Introduced migration 041 to promote the oldest admin user to superadmin if no superadmin exists. - Updated registration logic to assign the superadmin role to the first user and those in ADMIN_BOOTSTRAP_EMAILS. - Enhanced changelog to document the new version and changes made in this release.
This commit is contained in:
1 parent
9afcd762d0
commit
b661d0edb2
4 files changed
+37
-8
No files matched your search
@@ -187,9 +187,10 @@ def verification_link(token: str) -> str:
|
||||
|
||||
def registration_role(cur, email_lower: str) -> str:
|
||||
"""
|
||||
bootstrap: erste Registrierung in leerer DB → admin,
|
||||
bootstrap: erste Registrierung in leerer DB → superadmin,
|
||||
oder E-Mail ∈ ADMIN_BOOTSTRAP_EMAILS (kommasepariert, Groß/Klein egal).
|
||||
|
||||
superadmin deckt alle Portal-Rechte ab (inkl. löschen / andere Super-Admins).
|
||||
Um alle Self-Regs als Trainer zu haben: AUTO_ADMIN_FIRST_USER=false und keine ADMIN_BOOTSTRAP_EMAILS.
|
||||
"""
|
||||
bootstrap = {
|
||||
@@ -198,7 +199,7 @@ def registration_role(cur, email_lower: str) -> str:
|
||||
if x.strip()
|
||||
}
|
||||
if email_lower in bootstrap:
|
||||
return "admin"
|
||||
return "superadmin"
|
||||
if os.getenv("AUTO_ADMIN_FIRST_USER", "true").strip().lower() not in ("1", "true", "yes"):
|
||||
return "trainer"
|
||||
cur.execute("SELECT COUNT(*) AS n FROM profiles")
|
||||
@@ -207,7 +208,7 @@ def registration_role(cur, email_lower: str) -> str:
|
||||
n = int(row["n"]) if row is not None else 0
|
||||
except (KeyError, TypeError, ValueError):
|
||||
n = 0
|
||||
return "admin" if n == 0 else "trainer"
|
||||
return "superadmin" if n == 0 else "trainer"
|
||||
|
||||
|
||||
# ── Helper: Send Email ────────────────────────────────────────────────────────
|
||||
@@ -289,7 +290,7 @@ async def register(req: RegisterRequest, request: Request):
|
||||
verification_token = secrets.token_urlsafe(32)
|
||||
verification_expires = datetime.now(timezone.utc) + timedelta(hours=24)
|
||||
|
||||
# Rolle: erster Nutzer oder ADMIN_BOOTSTRAP_EMAILS → admin
|
||||
# Rolle: erster Nutzer oder ADMIN_BOOTSTRAP_EMAILS → superadmin
|
||||
role = registration_role(cur, email)
|
||||
|
||||
# Create profile (inactive until verified) — profiles.id ist SERIAL (INT), keine String-IDs einfügen.
|
||||
|
||||
Reference in new issue
Block a user