Führe Hauptnutzer und Mitarbeiter ein, damit der Betreiber Kunden und Hauptnutzer ihre Teams verwalten.
Eine Einladung erzeugt jetzt ein Mitarbeiter-Konto mit dem Eigentümer des Raums als Förderer. Mitarbeiter arbeiten nur in den eingeladenen Räumen nach ihrer Rolle, legen keine Räume und im persönlichen Raum nichts an und starten ihre Sitzung im Team-Raum. Einladen darf nur der Eigentümer als Hauptnutzer; nur ein Hauptnutzer kann Raum-Eigentümer sein. Hauptnutzer sehen unter Mein Team die Personen in ihren Räumen und verwalten ihre Mitarbeiter (deaktivieren, Einmal-Passwort, aus Räumen entfernen). Der Betreiber sieht die Team-Übersicht mit CSV-Export und macht einen Mitarbeiter zum Hauptnutzer. Eine zentrale Prüfstelle für Grenzen (access/limits.py) wird beim Anlegen von Räumen und beim Aufnehmen und Einladen von Mitgliedern aufgerufen; Tarife folgen später. Die lokale Suite läuft mit 143 Tests grün, der Frontend-Build und 24 Node-Tests ebenfalls. Die Oberfläche wurde noch nicht im Browser bedient. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e47f50d513
commit
6d7b7c5f85
26 files changed
+966
-43
No files matched your search
@@ -13,6 +13,7 @@ from app.access.roles import require_operator
|
||||
from app.api.deps import Principal, get_conn, get_principal, get_session
|
||||
from app.api.schemas import AccountIn, AccountPatchIn, PasswordChangeIn
|
||||
from app.auth.accounts import (
|
||||
promote_to_main,
|
||||
change_own_password,
|
||||
create_account,
|
||||
generate_password,
|
||||
@@ -40,6 +41,9 @@ def _account_item(row) -> dict:
|
||||
"must_change_password": row["must_change_password"],
|
||||
"created_at": dump_dt(row["created_at"]),
|
||||
"last_login_at": dump_dt(row["last_login_at"]),
|
||||
"account_kind": row["account_kind"],
|
||||
"sponsor_id": str(row["sponsor_id"]) if row["sponsor_id"] else None,
|
||||
"sponsor_name": row.get("sponsor_name"),
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +58,9 @@ def accounts(
|
||||
raise unprocessable("Der Statusfilter ist ungültig.")
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at,
|
||||
account_kind, sponsor_id,
|
||||
(SELECT s.display_name FROM auth_accounts s WHERE s.id = auth_accounts.sponsor_id) AS sponsor_name
|
||||
FROM auth_accounts
|
||||
WHERE origin = 'operator' AND (%s::text IS NULL OR status = %s::text)
|
||||
ORDER BY status, display_name, email
|
||||
@@ -69,7 +75,9 @@ def account_detail(account_id: UUID, principal: Principal = Depends(get_principa
|
||||
require_operator(conn, principal.account_id)
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at,
|
||||
account_kind, sponsor_id,
|
||||
(SELECT s.display_name FROM auth_accounts s WHERE s.id = auth_accounts.sponsor_id) AS sponsor_name
|
||||
FROM auth_accounts WHERE id = %s AND origin = 'operator'
|
||||
""",
|
||||
(account_id,),
|
||||
@@ -98,6 +106,16 @@ def account_detail(account_id: UUID, principal: Principal = Depends(get_principa
|
||||
{"id": str(room["id"]), "name": room["name"], "status": room["status"], "role": room["role"]} for room in rooms
|
||||
]
|
||||
body["active_sessions"] = sessions["n"]
|
||||
employees = conn.execute(
|
||||
"""
|
||||
SELECT id, display_name, email, status FROM auth_accounts
|
||||
WHERE sponsor_id = %s ORDER BY display_name, id
|
||||
""",
|
||||
(account_id,),
|
||||
).fetchall()
|
||||
body["employees"] = [
|
||||
{"id": str(e["id"]), "display_name": e["display_name"], "email": e["email"], "status": e["status"]} for e in employees
|
||||
]
|
||||
return JSONResponse(body, headers=_NO_STORE)
|
||||
|
||||
|
||||
@@ -123,6 +141,7 @@ def post_account(body: AccountIn, principal: Principal = Depends(get_principal),
|
||||
"is_superadmin": account["is_superadmin"],
|
||||
"status": account["status"],
|
||||
"must_change_password": True,
|
||||
"account_kind": account["account_kind"],
|
||||
}
|
||||
if not body.password:
|
||||
payload["temporary_password"] = password
|
||||
@@ -146,13 +165,17 @@ def patch_account(
|
||||
raise not_found()
|
||||
if body.display_name is not None:
|
||||
set_display_name(conn, principal.account_id, account_id, body.display_name)
|
||||
if body.account_kind == "main":
|
||||
promote_to_main(conn, principal.account_id, account_id)
|
||||
if body.is_operator is not None:
|
||||
set_operator(conn, principal.account_id, account_id, body.is_operator)
|
||||
if body.status is not None:
|
||||
set_status(conn, principal.account_id, account_id, body.status)
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at
|
||||
SELECT id, email, display_name, is_superadmin, status, must_change_password, created_at, last_login_at,
|
||||
account_kind, sponsor_id,
|
||||
(SELECT s.display_name FROM auth_accounts s WHERE s.id = auth_accounts.sponsor_id) AS sponsor_name
|
||||
FROM auth_accounts WHERE id = %s
|
||||
""",
|
||||
(account_id,),
|
||||
|
||||
Reference in new issue
Block a user