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
@@ -32,6 +32,7 @@ from app.access.policy import (
|
||||
require_matter,
|
||||
task_rights,
|
||||
)
|
||||
from app.access.limits import ensure_can_add_member
|
||||
from app.api.deps import Principal, get_conn, get_principal, get_session
|
||||
from app.api.schemas import (
|
||||
AcceptInviteIn,
|
||||
@@ -82,6 +83,7 @@ from app.api.schemas import (
|
||||
from app.auth.accounts import (
|
||||
clear_login_attempts,
|
||||
create_account,
|
||||
initial_scope,
|
||||
list_rooms,
|
||||
login_blocked,
|
||||
normalize_email,
|
||||
@@ -200,7 +202,7 @@ def _chapter_payload(row) -> dict:
|
||||
|
||||
def _session_body(conn, account_id: UUID, scope_kind: str, scope_id: UUID, csrf: str, epoch: int) -> dict:
|
||||
account = conn.execute(
|
||||
"SELECT id, email, display_name, is_superadmin, must_change_password FROM auth_accounts WHERE id = %s",
|
||||
"SELECT id, email, display_name, is_superadmin, must_change_password, account_kind FROM auth_accounts WHERE id = %s",
|
||||
(account_id,),
|
||||
).fetchone()
|
||||
room = conn.execute("SELECT id, kind, name FROM data_rooms WHERE id = %s", (scope_id,)).fetchone()
|
||||
@@ -211,6 +213,7 @@ def _session_body(conn, account_id: UUID, scope_kind: str, scope_id: UUID, csrf:
|
||||
"display_name": account["display_name"],
|
||||
"is_superadmin": account["is_superadmin"],
|
||||
"must_change_password": account["must_change_password"],
|
||||
"account_kind": account["account_kind"],
|
||||
},
|
||||
"scope": {"kind": scope_kind, "id": str(room["id"]), "name": room["name"]},
|
||||
"rooms": list_rooms(conn, account_id),
|
||||
@@ -241,7 +244,8 @@ def login(body: LoginIn, request: Request, conn: Connection = Depends(get_conn))
|
||||
clear_login_attempts(conn, bucket)
|
||||
settings = request.app.state.settings
|
||||
token, csrf = start_session(conn, settings, account["id"], device_label(request.headers.get("user-agent")))
|
||||
payload = _session_body(conn, account["id"], "personal", account["id"], csrf, 1)
|
||||
scope_kind, scope_id = initial_scope(conn, account["id"])
|
||||
payload = _session_body(conn, account["id"], scope_kind, scope_id, csrf, 1)
|
||||
response = JSONResponse(payload)
|
||||
set_session_cookie(response, request, settings, token)
|
||||
return response
|
||||
@@ -337,7 +341,19 @@ def accept_invite(
|
||||
raise not_found()
|
||||
if row["token_hash"] != hash_secret(body.token):
|
||||
raise not_found()
|
||||
account = create_account(conn, row["email"], body.display_name, body.password)
|
||||
room = conn.execute("SELECT owner_id FROM data_rooms WHERE id = %s AND status = 'active'", (row["room_id"],)).fetchone()
|
||||
if room is None:
|
||||
raise not_found()
|
||||
ensure_can_add_member(conn, room["owner_id"], row["room_id"])
|
||||
# An invitation creates an employee account. The owner of the room is the sponsor.
|
||||
account = create_account(
|
||||
conn,
|
||||
row["email"],
|
||||
body.display_name,
|
||||
body.password,
|
||||
account_kind="employee",
|
||||
sponsor_id=room["owner_id"],
|
||||
)
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO room_memberships (room_id, subject_id, role)
|
||||
@@ -349,7 +365,8 @@ def accept_invite(
|
||||
audit(conn, account["id"], row["room_id"], "invitation_accepted", "invitation", invitation_id)
|
||||
settings = request.app.state.settings
|
||||
token, csrf = start_session(conn, settings, account["id"], device_label(request.headers.get("user-agent")))
|
||||
payload = _session_body(conn, account["id"], "personal", account["id"], csrf, 1)
|
||||
scope_kind, scope_id = initial_scope(conn, account["id"])
|
||||
payload = _session_body(conn, account["id"], scope_kind, scope_id, csrf, 1)
|
||||
response = JSONResponse(status_code=201, content=payload)
|
||||
set_session_cookie(response, request, settings, token)
|
||||
return response
|
||||
|
||||
Reference in new issue
Block a user