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
@@ -10,9 +10,12 @@ from fastapi.responses import JSONResponse
|
||||
from psycopg import Connection
|
||||
|
||||
from app.access.policy import account_by_email, audit
|
||||
from app.access.limits import ensure_can_add_member, ensure_can_create_room
|
||||
from app.access.roles import (
|
||||
ROOM_ROLES,
|
||||
account_kind,
|
||||
count_active_managers,
|
||||
require_main_user,
|
||||
require_operator,
|
||||
require_room_manager,
|
||||
room_role,
|
||||
@@ -173,6 +176,8 @@ def rooms(
|
||||
|
||||
@router.post("/api/v1/rooms")
|
||||
def create_room(body: RoomIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||
require_main_user(conn, principal.account_id)
|
||||
ensure_can_create_room(conn, principal.account_id)
|
||||
room_id = uuid4()
|
||||
name = body.name.strip()
|
||||
conn.execute(
|
||||
@@ -281,6 +286,8 @@ def transfer_owner(
|
||||
account = conn.execute("SELECT status FROM auth_accounts WHERE id = %s", (body.subject_id,)).fetchone()
|
||||
if target is None or target["status"] != "active" or account is None or account["status"] != "active":
|
||||
raise unprocessable("Der Datenraum geht nur an ein aktives Mitglied.")
|
||||
if account_kind(conn, body.subject_id) != "main":
|
||||
raise unprocessable("Ein Mitarbeiter-Konto kann keinen Datenraum besitzen.")
|
||||
if body.subject_id == room["owner_id"]:
|
||||
raise unprocessable("Diese Person ist bereits Eigentümer.")
|
||||
_set_owner(conn, principal.account_id, room_id, body.subject_id, room["owner_id"])
|
||||
@@ -411,6 +418,8 @@ def add_member(
|
||||
if count_active_managers(conn, room_id, lock=True) <= 1:
|
||||
raise unprocessable("Der letzte Verwalter bleibt Verwalter.")
|
||||
was_active = bool(existing and existing["status"] == "active")
|
||||
if not was_active:
|
||||
ensure_can_add_member(conn, _room(conn, room_id)["owner_id"], room_id)
|
||||
_set_role(conn, principal.account_id, room_id, account["id"], body.role, added=not was_active)
|
||||
return {"subject_id": str(account["id"]), "role": body.role}
|
||||
|
||||
@@ -476,8 +485,10 @@ def invite(
|
||||
principal: Principal = Depends(get_principal),
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
require_room_manager(conn, principal.account_id, body.room_id)
|
||||
room = _room(conn, body.room_id)
|
||||
# Only the owner, a main user, brings new people in; they become employee accounts.
|
||||
room = _require_owner(conn, principal.account_id, body.room_id)
|
||||
require_main_user(conn, principal.account_id)
|
||||
ensure_can_add_member(conn, room["owner_id"], room["id"])
|
||||
email = normalize_email(body.email)
|
||||
if account_by_email(conn, email):
|
||||
raise unprocessable("Es gibt bereits ein Konto. Füge die Person als Mitglied hinzu.")
|
||||
@@ -627,6 +638,8 @@ def admin_set_owner(
|
||||
account = account_by_email(conn, body.email)
|
||||
if account is None or account["status"] != "active":
|
||||
raise not_found()
|
||||
if account_kind(conn, account["id"]) != "main":
|
||||
raise unprocessable("Ein Mitarbeiter-Konto kann keinen Datenraum besitzen.")
|
||||
_set_owner(conn, principal.account_id, room_id, account["id"], room["owner_id"])
|
||||
return {"owner_id": str(account["id"])}
|
||||
|
||||
|
||||
Reference in new issue
Block a user