Führe Hauptnutzer und Mitarbeiter ein, damit der Betreiber Kunden und Hauptnutzer ihre Teams verwalten.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 5m20s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 21s

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:
LarsandClaude Sonnet 5.5 committed 2026-10-22 09:03:40 +02:00
1 parent e47f50d513
commit 6d7b7c5f85
26 files changed
+966 -43

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
"""The one place where subscription limits will be checked.
Today there are no limits. The checks are called where a limit will matter, so that a plan
can be added without touching the callers.
Target model (see the entitlements blueprint): the quota subject is the owner of a room, a main
user, like the club at Shinkan. A plan, set by the operator, may later cap the number of active
employees per main user and per room. The count comes from the database, never from the client.
"""
from __future__ import annotations
from uuid import UUID
def ensure_can_create_room(conn, owner_id: UUID) -> None:
"""Called before a main user creates a room."""
del conn, owner_id
def ensure_can_add_member(conn, owner_id: UUID, room_id: UUID) -> None:
"""Called before a person becomes an active member of a room or is invited to it.
``owner_id`` is the owner of the room, the future quota subject.
"""
del conn, owner_id, room_id
+12
View File
@@ -19,6 +19,17 @@ ROOM_ROLE_LABELS = {
}
def account_kind(conn, account_id: UUID) -> str | None:
row = conn.execute("SELECT account_kind FROM auth_accounts WHERE id = %s AND status = 'active'", (account_id,)).fetchone()
return row["account_kind"] if row else None
def require_main_user(conn, account_id: UUID) -> None:
"""Employees work in the rooms they were invited to. They create no rooms of their own."""
if account_kind(conn, account_id) != "main":
raise forbidden("Als Mitarbeiter arbeitest du in den Räumen, in die du eingeladen wurdest.")
def is_operator(conn, account_id: UUID) -> bool:
row = conn.execute(
"SELECT is_superadmin FROM auth_accounts WHERE id = %s AND status = 'active'",
@@ -58,6 +69,7 @@ def require_room_write(conn, account_id: UUID, room: dict) -> None:
if room["kind"] == "personal":
if room["id"] != account_id:
raise forbidden("Der persönliche Datenraum gehört zu einem anderen Konto.")
require_main_user(conn, account_id)
return
role = room_role(conn, account_id, room["id"])
if role in {"member", "manager"}:
+26 -3
View File
@@ -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,),
+15 -2
View File
@@ -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"])}
+21 -4
View File
@@ -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
+5
View File
@@ -39,6 +39,11 @@ class AccountPatchIn(APIModel):
display_name: str | None = Field(default=None, min_length=1, max_length=120)
is_operator: bool | None = None
status: Literal["active", "disabled"] | None = None
account_kind: Literal["main"] | None = None
class TeamPatchIn(APIModel):
status: Literal["active", "disabled"]
class PasswordChangeIn(APIModel):
+245
View File
@@ -0,0 +1,245 @@
"""Team of a main user and the operator's overview of all teams.
A main user sees the people in the rooms he owns and manages the employees he invited.
The operator sees main users with their employees, rooms and roles: accounts and roles, never content.
"""
from __future__ import annotations
import csv
import io
from uuid import UUID
from fastapi import APIRouter, Depends, Response
from fastapi.responses import JSONResponse
from psycopg import Connection
from app.access.policy import audit
from app.access.roles import require_main_user, require_operator
from app.api.deps import Principal, get_conn, get_principal
from app.api.rooms import _audit_membership, _drop_shares_of
from app.api.schemas import TeamPatchIn
from app.auth.accounts import reset_password, set_status
from app.core.errors import forbidden
from app.core.timeutil import dump_dt
router = APIRouter()
_NO_STORE = {"Cache-Control": "no-store"}
def _own_employee(conn, owner_id: UUID, account_id: UUID) -> dict:
"""An employee this main user invited. Unknown and foreign accounts answer alike."""
row = conn.execute(
"SELECT id, status FROM auth_accounts WHERE id = %s AND account_kind = 'employee' AND sponsor_id = %s",
(account_id, owner_id),
).fetchone()
if row is None:
raise forbidden("Das ist keiner deiner Mitarbeiter.")
return row
@router.get("/api/v1/team")
def team(principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
require_main_user(conn, principal.account_id)
me = principal.account_id
people = conn.execute(
"""
SELECT DISTINCT a.id, a.display_name, a.email, a.status, a.account_kind, a.last_login_at,
(a.sponsor_id = %s) AS mine
FROM auth_accounts a
WHERE a.id <> %s AND (
a.sponsor_id = %s
OR EXISTS (
SELECT 1 FROM room_memberships m JOIN data_rooms r ON r.id = m.room_id
WHERE m.subject_id = a.id AND m.status = 'active'
AND r.kind = 'organization' AND r.owner_id = %s
)
)
ORDER BY a.display_name, a.id
""",
(me, me, me, me),
).fetchall()
rooms = conn.execute(
"""
SELECT m.subject_id, r.id AS room_id, r.name, r.status, m.role
FROM room_memberships m JOIN data_rooms r ON r.id = m.room_id
WHERE m.status = 'active' AND r.kind = 'organization' AND r.owner_id = %s AND m.subject_id <> %s
ORDER BY r.name, r.id
""",
(me, me),
).fetchall()
by_person: dict = {}
for row in rooms:
by_person.setdefault(row["subject_id"], []).append(
{"room_id": str(row["room_id"]), "name": row["name"], "archived": row["status"] != "active", "role": row["role"]}
)
return JSONResponse(
{
"items": [
{
"id": str(person["id"]),
"display_name": person["display_name"],
"email": person["email"],
"status": person["status"],
"account_kind": person["account_kind"],
"last_login_at": dump_dt(person["last_login_at"]),
"mine": person["mine"],
"rooms": by_person.get(person["id"], []),
}
for person in people
]
},
headers=_NO_STORE,
)
@router.patch("/api/v1/team/{account_id}")
def patch_team_member(
account_id: UUID,
body: TeamPatchIn,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
require_main_user(conn, principal.account_id)
_own_employee(conn, principal.account_id, account_id)
set_status(conn, principal.account_id, account_id, body.status)
return {"id": str(account_id), "status": body.status}
@router.post("/api/v1/team/{account_id}/password-reset")
def reset_team_password(
account_id: UUID,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
require_main_user(conn, principal.account_id)
_own_employee(conn, principal.account_id, account_id)
password = reset_password(conn, principal.account_id, account_id)
audit(conn, principal.account_id, None, "employee_password_reset", "account", account_id)
return JSONResponse({"temporary_password": password}, headers=_NO_STORE)
@router.delete("/api/v1/team/{account_id}/memberships", status_code=204)
def remove_from_my_rooms(
account_id: UUID,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
"""End the memberships of one person in all rooms this main user owns."""
require_main_user(conn, principal.account_id)
rows = conn.execute(
"""
SELECT m.room_id FROM room_memberships m JOIN data_rooms r ON r.id = m.room_id
WHERE m.subject_id = %s AND m.status = 'active' AND r.kind = 'organization' AND r.owner_id = %s
FOR UPDATE OF m
""",
(account_id, principal.account_id),
).fetchall()
if account_id == principal.account_id or not rows:
raise forbidden("Diese Person ist in keinem deiner Räume Mitglied.")
for row in rows:
room_id = row["room_id"]
conn.execute(
"UPDATE room_memberships SET status = 'removed' WHERE room_id = %s AND subject_id = %s",
(room_id, account_id),
)
_drop_shares_of(conn, room_id, account_id)
conn.execute(
"""
UPDATE auth_sessions
SET scope_kind = 'personal', scope_id = account_id, epoch = epoch + 1
WHERE account_id = %s AND scope_id = %s AND revoked_at IS NULL
""",
(account_id, room_id),
)
_audit_membership(conn, principal.account_id, room_id, account_id, "membership_removed")
audit(conn, principal.account_id, None, "employee_removed", "account", account_id, detail={"rooms": len(rows)})
return Response(status_code=204)
def _csv_cell(value) -> str:
text = "" if value is None else str(value)
# A cell that starts like a formula would run in a spreadsheet.
return "'" + text if text[:1] in {"=", "+", "-", "@", "\t", "\r"} else text
@router.get("/api/v1/admin/team")
def admin_team(
format: str = "json",
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
"""Main users with their employees, rooms and roles. Metadata only."""
require_operator(conn, principal.account_id)
owners = conn.execute(
"""
SELECT a.id, a.display_name, a.email, a.status
FROM auth_accounts a
WHERE a.account_kind = 'main'
AND (EXISTS (SELECT 1 FROM auth_accounts e WHERE e.sponsor_id = a.id)
OR EXISTS (SELECT 1 FROM data_rooms r WHERE r.owner_id = a.id AND r.kind = 'organization'))
ORDER BY a.display_name, a.id
"""
).fetchall()
employees = conn.execute(
"""
SELECT e.id, e.sponsor_id, e.display_name, e.email, e.status, e.last_login_at
FROM auth_accounts e WHERE e.account_kind = 'employee'
ORDER BY e.display_name, e.id
"""
).fetchall()
memberships = conn.execute(
"""
SELECT m.subject_id, r.id AS room_id, r.name, r.status, r.owner_id, m.role
FROM room_memberships m JOIN data_rooms r ON r.id = m.room_id
WHERE m.status = 'active' AND r.kind = 'organization'
ORDER BY r.name, r.id
"""
).fetchall()
rooms_of: dict = {}
for row in memberships:
rooms_of.setdefault(row["subject_id"], []).append(row)
result = []
for owner in owners:
mine = [e for e in employees if e["sponsor_id"] == owner["id"]]
result.append(
{
"id": str(owner["id"]),
"display_name": owner["display_name"],
"email": owner["email"],
"status": owner["status"],
"employees": [
{
"id": str(e["id"]),
"display_name": e["display_name"],
"email": e["email"],
"status": e["status"],
"last_login_at": dump_dt(e["last_login_at"]),
"rooms": [
{"room_id": str(r["room_id"]), "name": r["name"], "archived": r["status"] != "active", "role": r["role"]}
for r in rooms_of.get(e["id"], [])
],
}
for e in mine
],
}
)
if format == "csv":
out = io.StringIO()
writer = csv.writer(out)
writer.writerow(["Hauptnutzer", "Mitarbeiter", "E-Mail", "Status", "Datenraum", "Rolle"])
for owner in result:
for e in owner["employees"]:
if not e["rooms"]:
writer.writerow([_csv_cell(v) for v in (owner["display_name"], e["display_name"], e["email"], e["status"], "", "")])
for room in e["rooms"]:
writer.writerow(
[_csv_cell(v) for v in (owner["display_name"], e["display_name"], e["email"], e["status"], room["name"], room["role"])]
)
return Response(
content=out.getvalue(),
media_type="text/csv; charset=utf-8",
headers={"Content-Disposition": 'attachment; filename="team-uebersicht.csv"', **_NO_STORE},
)
return JSONResponse({"items": result}, headers=_NO_STORE)
+42 -6
View File
@@ -46,11 +46,15 @@ def create_account(
is_superadmin: bool = False,
origin: str = "operator",
must_change_password: bool = False,
account_kind: str = "main",
sponsor_id: UUID | None = None,
) -> dict:
email = normalize_email(email)
display_name = display_name.strip()
if origin not in {"operator", "fixture"}:
raise unprocessable("Die Kontenherkunft ist ungültig.")
if account_kind not in {"main", "employee"} or (account_kind == "employee") != (sponsor_id is not None):
raise unprocessable("Die Kontoart ist ungültig.")
check_password_policy(password)
if conn.execute("SELECT 1 FROM auth_accounts WHERE email = %s", (email,)).fetchone():
raise unprocessable("Für diese E-Mail gibt es bereits ein Konto.")
@@ -60,11 +64,14 @@ def create_account(
"""
INSERT INTO auth_accounts (
id, email, display_name, password_hash, is_superadmin, origin,
must_change_password, password_changed_at
must_change_password, password_changed_at, account_kind, sponsor_id
)
VALUES (%s, %s, %s, %s, %s, %s, %s, now())
VALUES (%s, %s, %s, %s, %s, %s, %s, now(), %s, %s)
""",
(account_id, email, display_name, password_hash, is_superadmin, origin, must_change_password),
(
account_id, email, display_name, password_hash, is_superadmin, origin,
must_change_password, account_kind, sponsor_id,
),
)
conn.execute(
"""
@@ -75,25 +82,54 @@ def create_account(
)
return conn.execute(
"""
SELECT id, email, display_name, is_superadmin, status, must_change_password
SELECT id, email, display_name, is_superadmin, status, must_change_password, account_kind
FROM auth_accounts WHERE id = %s
""",
(account_id,),
).fetchone()
def promote_to_main(conn, actor: UUID, account_id: UUID) -> None:
"""Only the operator turns an employee into a main user."""
account = _account(conn, account_id, lock=True)
if account["account_kind"] == "main":
return
conn.execute("UPDATE auth_accounts SET account_kind = 'main', sponsor_id = NULL WHERE id = %s", (account_id,))
# A raised kind starts from a fresh login.
revoke_sessions(conn, account_id)
audit(conn, actor, None, "employee_promoted", "account", account_id)
def initial_scope(conn, account_id: UUID) -> tuple[str, UUID]:
"""Where a new session starts: the personal room, or for an employee the first team room."""
account = conn.execute("SELECT account_kind FROM auth_accounts WHERE id = %s", (account_id,)).fetchone()
if account is not None and account["account_kind"] == "employee":
room = conn.execute(
"""
SELECT r.id FROM room_memberships m JOIN data_rooms r ON r.id = m.room_id
WHERE m.subject_id = %s AND m.status = 'active' AND r.kind = 'organization' AND r.status = 'active'
ORDER BY r.name, r.id LIMIT 1
""",
(account_id,),
).fetchone()
if room is not None:
return "organization", room["id"]
return "personal", account_id
def start_session(conn, settings: Settings, account_id: UUID, label: str | None = None) -> tuple[str, str]:
token = new_secret()
csrf = new_secret()
scope_kind, scope_id = initial_scope(conn, account_id)
session = conn.execute(
"""
INSERT INTO auth_sessions (
account_id, secret_hash, csrf_token, scope_kind, scope_id, expires_at, label, last_seen_at
)
VALUES (%s, %s, %s, 'personal', %s, %s, %s, now())
VALUES (%s, %s, %s, %s, %s, %s, %s, now())
RETURNING id
""",
(account_id, hash_secret(token), csrf, account_id, session_expiry(settings), (label or None) and label[:80]),
(account_id, hash_secret(token), csrf, scope_kind, scope_id, session_expiry(settings), (label or None) and label[:80]),
).fetchone()
conn.execute("UPDATE auth_accounts SET last_login_at = now() WHERE id = %s", (account_id,))
audit(conn, account_id, None, "session_started", "session", session["id"])
+2
View File
@@ -14,6 +14,7 @@ from app.api.correspondence import router as correspondence_router
from app.api.export import router as export_router
from app.api.rooms import router as rooms_router
from app.api.roomshare import router as roomshare_router
from app.api.team import router as team_router
from app.api.routes import router
from app.api.sources import router as sources_router
from app.core.errors import Problem, problem_response
@@ -122,6 +123,7 @@ def create_app() -> FastAPI:
app.include_router(accounts_router)
app.include_router(rooms_router)
app.include_router(roomshare_router)
app.include_router(team_router)
app.include_router(sources_router)
app.include_router(export_router)
app.include_router(correspondence_router)
+5
View File
@@ -1068,6 +1068,11 @@ LABELS = {
"invitation_revoked": "Einladung widerrufen",
"invitation_accepted": "Einladung angenommen",
"visibility_changed": "Raumfreigabe geändert",
"employee_promoted": "Mitarbeiter zum Hauptnutzer gemacht",
"employee_disabled": "Mitarbeiter-Konto deaktiviert",
"employee_enabled": "Mitarbeiter-Konto aktiviert",
"employee_password_reset": "Passwort eines Mitarbeiters zurückgesetzt",
"employee_removed": "Mitarbeiter aus allen Räumen entfernt",
"room_shared": "Mit Datenraum geteilt",
"room_share_changed": "Freigabe an Datenraum geändert",
"room_unshared": "Freigabe an Datenraum beendet",
@@ -0,0 +1,13 @@
-- Hauptnutzer und Mitarbeiter. Alle bestehenden Konten sind Hauptnutzer.
-- Ein Mitarbeiter-Konto entsteht durch eine Einladung und hat den einladenden Eigentümer als Förderer.
ALTER TABLE auth_accounts
ADD COLUMN account_kind text NOT NULL DEFAULT 'main',
ADD COLUMN sponsor_id uuid REFERENCES auth_accounts (id),
ADD CONSTRAINT auth_accounts_kind CHECK (account_kind IN ('main', 'employee')),
ADD CONSTRAINT auth_accounts_sponsor CHECK (
(account_kind = 'employee' AND sponsor_id IS NOT NULL)
OR (account_kind = 'main' AND sponsor_id IS NULL)
);
CREATE INDEX auth_accounts_sponsor ON auth_accounts (sponsor_id) WHERE sponsor_id IS NOT NULL;
+220
View File
@@ -0,0 +1,220 @@
"""Hauptnutzer, Mitarbeiter und Teamverwaltung."""
from __future__ import annotations
import uuid
import pytest
from fastapi.testclient import TestClient
from app.auth.accounts import create_account
from app.core.errors import unprocessable
from tests.support import ORIGIN, PASSWORD, Actor
def _second_client():
from app.main import app
return TestClient(app)
def _main(client, db, key: str, *, main: bool = False, superadmin: bool = False) -> Actor:
actor = Actor(client if main else _second_client(), f"{key}-team@example.test", key.title())
create_account(db, actor.email, actor.name, PASSWORD, is_superadmin=superadmin)
db.commit()
actor.login()
return actor
def _invite(owner: Actor, room: str, email: str, role: str = "member", name: str = "Mitarbeiter") -> Actor:
invited = owner.request("POST", "/api/v1/invitations", json={"email": email, "room_id": room, "role": role}, status=201)
client = _second_client()
response = client.post(
f"/api/v1/invitations/{invited['id']}/accept",
json={"token": invited["token"], "display_name": name, "password": PASSWORD},
headers={"Origin": ORIGIN},
)
assert response.status_code == 201, response.text
employee = Actor(client, email, name)
employee.login()
return employee
def _id(db, email: str) -> str:
row = db.execute("SELECT id FROM auth_accounts WHERE email = %s", (email,)).fetchone()
db.rollback()
return str(row["id"])
@pytest.fixture
def world(client, db):
ada = _main(client, db, "ada", main=True)
room = ada.request("POST", "/api/v1/rooms", json={"name": "Kanzlei"}, status=201)["id"]
ada.use_room(room)
employee = _invite(ada, room, "emp-team@example.test", name="Eva Mitarbeiterin")
return {"ada": ada, "room": room, "emp": employee}
def test_an_invitation_creates_an_employee_account_sponsored_by_the_owner(world, db):
row = db.execute("SELECT account_kind, sponsor_id FROM auth_accounts WHERE email = 'emp-team@example.test'").fetchone()
db.rollback()
assert row["account_kind"] == "employee"
assert str(row["sponsor_id"]) == _id(db, world["ada"].email)
assert world["emp"].request("GET", "/api/v1/auth/session")["account"]["account_kind"] == "employee"
assert world["ada"].request("GET", "/api/v1/auth/session")["account"]["account_kind"] == "main"
def test_an_employee_works_only_in_the_rooms_he_was_invited_to(world, db):
emp, room = world["emp"], world["room"]
emp.request("POST", "/api/v1/rooms", json={"name": "Eigener Raum"}, status=403)
# The session starts in the team room, not in a personal room.
assert emp.scope["kind"] == "organization" and emp.scope["id"] == room
# In the personal room nothing is created.
personal = emp.request("POST", "/api/v1/auth/session/scope", json={"kind": "personal", "id": _id(db, emp.email)})
emp.scope, emp.csrf = personal["scope"], personal["csrf_token"]
emp.request("POST", "/api/v1/cases", json={"title": "Privat"}, status=403)
emp.request("POST", "/api/v1/matters", json={"title": "Privat"}, status=403)
emp.use_room(room)
case = emp.request("POST", "/api/v1/cases", json={"title": "Im Team"}, status=201)
world["ada"].request("GET", f"/api/v1/cases/{case['id']}")
# Rights follow the role: a reader only reads.
world["ada"].request("PATCH", f"/api/v1/rooms/{room}/members/{_id(db, emp.email)}", json={"role": "reader"})
emp.request("POST", "/api/v1/cases", json={"title": "Nicht mehr"}, status=403)
emp.request("GET", f"/api/v1/cases/{case['id']}")
def test_only_the_owner_invites_and_an_employee_never_does(world, client, db):
ada, emp, room = world["ada"], world["emp"], world["room"]
ben = _main(client, db, "ben")
ada.request("POST", f"/api/v1/rooms/{room}/members", json={"email": ben.email, "role": "manager"})
ben.use_room(room)
# A manager who is not the owner adds existing accounts but creates no new ones.
ben.request("POST", "/api/v1/invitations", json={"email": "neu-team@example.test", "room_id": room}, status=403)
ben.request("POST", f"/api/v1/rooms/{room}/members", json={"email": emp.email, "role": "reader"})
emp.request("POST", "/api/v1/invitations", json={"email": "neu-team@example.test", "room_id": room}, status=403)
def test_an_employee_cannot_own_a_room(world, db):
ada, emp, room = world["ada"], world["emp"], world["room"]
ada.request("POST", f"/api/v1/rooms/{room}/owner", json={"subject_id": _id(db, emp.email)}, status=422)
operator = _main(world["ada"].client.__class__ and _second_client(), db, "betreiber", superadmin=True)
db.execute("UPDATE auth_accounts SET status = 'disabled' WHERE id = %s", (_id(db, ada.email),))
db.commit()
operator.request("POST", f"/api/v1/admin/rooms/{room}/owner", json={"email": emp.email}, status=422)
def test_my_team_lists_only_people_in_my_rooms_and_acts_only_on_my_employees(world, client, db):
ada, emp = world["ada"], world["emp"]
cara = _main(client, db, "cara")
emp_id = _id(db, emp.email)
listed = ada.request("GET", "/api/v1/team")["items"]
assert [(p["email"], p["mine"], p["rooms"][0]["role"]) for p in listed] == [(emp.email, True, "member")]
assert cara.request("GET", "/api/v1/team")["items"] == []
emp.request("GET", "/api/v1/team", status=403)
unknown = str(uuid.uuid4())
for actor in (cara,):
foreign = actor.request("PATCH", f"/api/v1/team/{emp_id}", json={"status": "disabled"}, status=403)
missing = actor.request("PATCH", f"/api/v1/team/{unknown}", json={"status": "disabled"}, status=403)
assert foreign["detail"] == missing["detail"]
actor.request("POST", f"/api/v1/team/{emp_id}/password-reset", status=403)
actor.request("DELETE", f"/api/v1/team/{emp_id}/memberships", status=403)
# A main user is not a sponsored employee: no team action on him, not even by the owner.
cara_id = _id(db, cara.email)
ada.request("PATCH", f"/api/v1/team/{cara_id}", json={"status": "disabled"}, status=403)
ada.request("POST", f"/api/v1/team/{cara_id}/password-reset", status=403)
def test_the_owner_disables_resets_and_removes_an_employee(world, db):
ada, emp, room = world["ada"], world["emp"], world["room"]
emp_id = _id(db, emp.email)
ada.request("PATCH", f"/api/v1/team/{emp_id}", json={"status": "disabled"})
emp.request("GET", "/api/v1/auth/session", status=401)
login = emp.client.post("/api/v1/auth/login", json={"email": emp.email, "password": PASSWORD}, headers={"Origin": ORIGIN})
assert login.status_code == 401
ada.request("PATCH", f"/api/v1/team/{emp_id}", json={"status": "active"})
reset = ada.request("POST", f"/api/v1/team/{emp_id}/password-reset")
emp.password = reset["temporary_password"]
assert emp.login()["account"]["must_change_password"] is True
emp.request("GET", "/api/v1/cases", status=403)
ada.request("DELETE", f"/api/v1/team/{emp_id}/memberships", status=204)
assert ada.request("GET", "/api/v1/team")["items"][0]["rooms"] == []
# Without a room the employee lands in the personal room, where he can do nothing but change his password.
assert emp.login()["scope"]["kind"] == "personal"
ada.request("DELETE", f"/api/v1/team/{emp_id}/memberships", status=403)
ada.request("DELETE", f"/api/v1/team/{_id(db, ada.email)}/memberships", status=403)
assert room
def test_the_operator_sees_the_teams_as_metadata_and_exports_them_safely(world, client, db):
ada, room = world["ada"], world["room"]
_invite(ada, room, "formel-team@example.test", role="reader", name="=SUM(1+1)")
operator = _main(_second_client(), db, "betreiber", superadmin=True)
note = ada.request("POST", "/api/v1/cases", json={"title": "Geheimer Inhalt"}, status=201)
overview = operator.request("GET", "/api/v1/admin/team")["items"]
owner = next(item for item in overview if item["email"] == ada.email)
assert {e["email"] for e in owner["employees"]} == {"emp-team@example.test", "formel-team@example.test"}
assert all(r["name"] == "Kanzlei" for e in owner["employees"] for r in e["rooms"])
assert "Geheimer Inhalt" not in str(overview) and note["title"] == "Geheimer Inhalt"
response = operator.client.get(
"/api/v1/admin/team",
params={"format": "csv"},
headers={"Origin": ORIGIN, "X-Scope-Kind": operator.scope["kind"], "X-Scope-Id": operator.scope["id"]},
)
assert response.status_code == 200 and response.headers["content-type"].startswith("text/csv")
lines = response.text.splitlines()
assert lines[0] == "Hauptnutzer,Mitarbeiter,E-Mail,Status,Datenraum,Rolle"
assert any("'=SUM(1+1)" in line for line in lines)
assert not any(line.split(",")[1].startswith("=") for line in lines[1:])
world["emp"].request("GET", "/api/v1/admin/team", status=403)
ada.request("GET", "/api/v1/admin/team", status=403)
def test_only_the_operator_promotes_an_employee(world, client, db):
ada, emp, room = world["ada"], world["emp"], world["room"]
emp_id = _id(db, emp.email)
ada.request("PATCH", f"/api/v1/accounts/{emp_id}", json={"account_kind": "main"}, status=403)
operator = _main(_second_client(), db, "betreiber", superadmin=True)
listed = {a["email"]: a for a in operator.request("GET", "/api/v1/accounts")["items"]}
assert listed[emp.email]["account_kind"] == "employee" and listed[emp.email]["sponsor_name"] == "Ada"
assert operator.request("GET", f"/api/v1/accounts/{_id(db, ada.email)}")["employees"][0]["email"] == emp.email
operator.request("PATCH", f"/api/v1/accounts/{emp_id}", json={"account_kind": "main"})
emp.request("GET", "/api/v1/cases", status=401)
fresh = Actor(emp.client, emp.email, emp.name)
assert fresh.login()["account"]["account_kind"] == "main"
fresh.request("POST", "/api/v1/rooms", json={"name": "Eigener Raum"}, status=201)
assert room
def test_limits_have_one_place_and_are_checked_where_they_matter(world, client, db, monkeypatch):
ada, room = world["ada"], world["room"]
seen = []
def block_room(conn, owner_id):
seen.append(("room", owner_id))
raise unprocessable("Grenze erreicht.")
def block_member(conn, owner_id, room_id):
seen.append(("member", owner_id, room_id))
raise unprocessable("Grenze erreicht.")
cem = _main(client, db, "cem")
monkeypatch.setattr("app.api.rooms.ensure_can_create_room", block_room)
ada.request("POST", "/api/v1/rooms", json={"name": "Noch ein Raum"}, status=422)
monkeypatch.setattr("app.api.rooms.ensure_can_add_member", block_member)
ada.request("POST", f"/api/v1/rooms/{room}/members", json={"email": cem.email, "role": "member"}, status=422)
ada.request("POST", "/api/v1/invitations", json={"email": "grenze-team@example.test", "room_id": room}, status=422)
assert [entry[0] for entry in seen] == ["room", "member", "member"]
assert all(entry[1] == uuid.UUID(_id(db, ada.email)) for entry in seen)
# Changing the role of an existing member needs no check.
monkeypatch.undo()
invited = ada.request("POST", "/api/v1/invitations", json={"email": "spaet-team@example.test", "room_id": room}, status=201)
monkeypatch.setattr("app.api.routes.ensure_can_add_member", block_member)
refused = _second_client().post(
f"/api/v1/invitations/{invited['id']}/accept",
json={"token": invited["token"], "display_name": "Spät", "password": PASSWORD},
headers={"Origin": ORIGIN},
)
assert refused.status_code == 422
assert db.execute("SELECT 1 FROM auth_accounts WHERE email = 'spaet-team@example.test'").fetchone() is None
db.rollback()
+6 -1
View File
@@ -41,7 +41,7 @@ Legende Spalte „Auth“: **–** öffentlich, **S** gültige Session, **S+R**
| GET | `/api/v1/accounts` | S+R, B | Betreiberkonten (`origin='operator'`) mit Status, Rolle, letzter Anmeldung; Filter `status=active\|disabled` |
| GET | `/api/v1/accounts/{id}` | S+R, B | Detail mit Raummitgliedschaften und Zahl aktiver Sitzungen |
| POST | `/api/v1/accounts` | S+R, B | Konto anlegen, persönlicher Raum, `must_change_password`. Ohne `password` erzeugt der Server ein Einmal-Passwort und liefert es einmal als `temporary_password`. `is_operator` optional |
| PATCH | `/api/v1/accounts/{id}` | S+R, B | `display_name`, `is_operator`, `status` (`active`/`disabled`). Letzter Betreiber und eigenes Konto sind geschützt |
| PATCH | `/api/v1/accounts/{id}` | S+R, B | `display_name`, `is_operator`, `status` (`active`/`disabled`), `account_kind: main` (Mitarbeiter zum Hauptnutzer machen). Letzter Betreiber und eigenes Konto sind geschützt |
| POST | `/api/v1/accounts/{id}/password-reset` | S+R, B | neues Einmal-Passwort, beendet alle Sitzungen; nicht für das eigene Konto |
| POST | `/api/v1/accounts/{id}/sessions/revoke` | S+R, B | alle Sitzungen des Kontos beenden |
| POST | `/api/v1/auth/password` | S | eigenes Passwort ändern (`current_password`, `new_password`); beendet die anderen Sitzungen; 204. Erlaubt auch bei `must_change_password` |
@@ -72,6 +72,11 @@ Legende Spalte „Auth“: **–** öffentlich, **S** gültige Session, **S+R**
| PUT / DELETE | `/api/v1/cases/{id}/room-share/rooms/{room_id}`, `/api/v1/matters/{id}/room-share/rooms/{room_id}` | S+R, Owner | mit dem Raum teilen (`access`: `edit` = Rechte nach Rolle, `read` = höchstens Lesen) oder die Freigabe beenden; nur in Räumen, in denen der Owner Mitglied oder Verwalter ist |
| PUT | `/api/v1/cases/{id}/room-share/people/{subject_id}`, `/api/v1/matters/{id}/room-share/people/{subject_id}` | S+R, Owner | eine Person von der Raumfreigabe ausnehmen (`excluded`) |
| POST | `/api/v1/admin/rooms/{id}/owner` | S+R, B | Betreiber setzt einen Eigentümer ein, nur wenn der bisherige nicht mehr handeln kann (Konto deaktiviert oder nicht mehr Mitglied) |
| GET | `/api/v1/team` | S+R, Hauptnutzer | Personen in den eigenen Räumen mit Rolle je Raum; `mine` = selbst eingeladen |
| PATCH | `/api/v1/team/{id}` | S+R, Hauptnutzer | `status` eines selbst eingeladenen Mitarbeiters; fremde und unbekannte ID: 403 |
| POST | `/api/v1/team/{id}/password-reset` | S+R, Hauptnutzer | Einmal-Passwort für einen selbst eingeladenen Mitarbeiter |
| DELETE | `/api/v1/team/{id}/memberships` | S+R, Hauptnutzer | Person aus allen eigenen Räumen entfernen |
| GET | `/api/v1/admin/team` | S+R, B | Hauptnutzer mit Mitarbeitern, Räumen und Rollen; `format=csv` für den Export |
| GET | `/api/v1/admin/rooms` | S+R, B | alle gemeinsamen Räume mit Zustand, Mitgliederzahl, Verwaltern; keine Inhalte |
| POST | `/api/v1/admin/rooms/{id}/managers` | S+R, B | Verwalter einsetzen, nur wenn der Raum keinen aktiven Verwalter hat |
| GET | `/api/v1/admin/events` | S+R, B | Verwaltungsprotokoll (`cursor`, `limit`) für Konto, Sitzung, Raum, Mitgliedschaft, Einladung |
+18
View File
@@ -64,3 +64,21 @@ MFA (später optional für alle Konten), Leerlaufablauf und Rotation der Sitzung
- **Eine Stelle für Datenräume:** Verwaltung → Datenräume listet alle eigenen Räume mit Zustand, Rolle und Eigentümer. Ein Klick öffnet die Verwaltung des Raums (`/rooms/{id}`): Mitglieder, Rollen, Einladungen, Umbenennen, Voreinstellung, Übertragung, Archivieren. Dafür ist kein Wechsel in den Raum nötig. Der Betreiber sieht darunter zusätzlich alle Räume mit Eigentümer und Verwalter.
- **Nutzer ist etwas anderes:** Verwaltung → Nutzer (nur Betreiber) verwaltet Konten, Verwaltungsprotokoll das Audit. Mein Konto betrifft das eigene Passwort und die Geräte.
- **Ziehen zum Teilen:** In den Listen Akten und Vorgänge zeigt eine Leiste die Räume, in denen man schreiben darf. Eigene Einträge lassen sich darauf ziehen und werden mit dem Raum geteilt. Die Liste zeigt „geteilt mit …“. Ohne Maus: Eintrag öffnen und Teilen wählen.
## Betreiber, Hauptnutzer und Mitarbeiter (seit 22.10.2026)
| Ebene | Kontoart | Aufgabe |
|---|---|---|
| Betreiber | Hauptnutzer mit `is_superadmin` | SaaS-Betreiber: verwaltet Hauptnutzer, sieht Räume und Team-Übersicht (Metadaten), keine Inhalte |
| Hauptnutzer | `account_kind = main` | privater Raum und eigene Team-Räume; Eigentümer; lädt Mitarbeiter ein und verwaltet sie |
| Mitarbeiter | `account_kind = employee` | arbeitet nur in eingeladenen Räumen nach Raumrolle; legt keine Räume an; kein privater Arbeitsbereich |
- **Einladung:** nur der Eigentümer des Raums (als Hauptnutzer). Das neue Konto ist ein Mitarbeiter; `sponsor_id` ist der Eigentümer. Ein Verwalter ohne Eigentum nimmt nur bestehende Konten auf.
- **Mitarbeiter-Sitzung:** beginnt im ersten Team-Raum, in dem die Person Mitglied ist. Im persönlichen Raum legt ein Mitarbeiter nichts an. Ohne Raum kann er sich anmelden, aber nichts tun.
- **Eigentümer:** nur ein Hauptnutzer kann Raum-Eigentümer sein, auch bei Übertragung und beim Einsetzen durch den Betreiber.
- **Mein Team** (`/team`): zeigt die Personen in den eigenen Räumen mit Rolle je Raum. Für selbst eingeladene Mitarbeiter: deaktivieren/aktivieren, Einmal-Passwort, Entfernen aus allen eigenen Räumen. Fremde und unbekannte Konten antworten gleich mit 403.
- **Betreiber:** `/admin/team` zeigt Hauptnutzer mit ihren Mitarbeitern, Räumen und Rollen (auch als CSV, mit Schutz vor Formeleingabe). Nur der Betreiber macht einen Mitarbeiter zum Hauptnutzer; die Person meldet sich dann neu an.
### Vorbereitung Subscription
`backend/app/access/limits.py` ist die einzige Stelle für Grenzen. `ensure_can_create_room(conn, owner_id)` läuft beim Anlegen eines Raums, `ensure_can_add_member(conn, owner_id, room_id)` beim Aufnehmen, Einladen und Annehmen einer Einladung. Heute lassen beide alles zu. Das Kontingentsubjekt ist der Eigentümer des Raums, ein Hauptnutzer, wie der Verein bei Shinkan (Entitlements-Blueprint). Vorgesehene Messgrößen: aktive Mitarbeiter je Hauptnutzer und je Raum, aus der Datenbank gezählt. Der Betreiber setzt den Plan. Zahlungsdienst und Tarife gehören nicht in diese Stufe. Offene Entscheidung: Ein Mitarbeiter, den ein zweiter Hauptnutzer als bestehendes Konto aufnimmt, zählt beim Raum-Eigentümer; die Zuständigkeit bei Grenzen klärt das Tarifkonzept.
+2 -2
View File
@@ -1,6 +1,6 @@
# Tsumugu – Datenmodell (Ist-Stand)
**Stand:** 19.10.2026, nach den Migrationen in `backend/migrations/` (letzte: `20261021T150000Z_room_shares.sql`). Entstanden im Code-Review vom 18.10.2026 und für die Connector-Grundlage nachgezogen. Die Arten `connectors.kind` und `external_references.source` prüft die Registrierung. Die früheren Prüflisten in der Datenbank sind entfernt. `url` bleibt eine Referenz ohne Connector.
**Stand:** 19.10.2026, nach den Migrationen in `backend/migrations/` (letzte: `20261022T090000Z_account_kinds.sql`). Entstanden im Code-Review vom 18.10.2026 und für die Connector-Grundlage nachgezogen. Die Arten `connectors.kind` und `external_references.source` prüft die Registrierung. Die früheren Prüflisten in der Datenbank sind entfernt. `url` bleibt eine Referenz ohne Connector.
Die Sollfassung steht in der [technischen Spezifikation, Abschnitt 4](TSUMUGU_TECHNICAL_SPEC.md). Diese Datei beschreibt, was tatsächlich angelegt ist. Bei jeder neuen Migration nachziehen.
@@ -16,7 +16,7 @@ Die Sollfassung steht in der [technischen Spezifikation, Abschnitt 4](TSUMUGU_TE
| Tabelle | Wesentliche Spalten | Regeln |
|---|---|---|
| `auth_accounts` | `id`, `email` (unique), `display_name`, `password_hash` (bcrypt), `status` (`active`/`disabled`), `is_superadmin`, `origin` (`operator`/`fixture`), `must_change_password`, `password_changed_at`, `last_login_at`, `disabled_at`, `disabled_by` | Konten mit `origin='fixture'` entfernt der Start in jeder Umgebung |
| `auth_accounts` | `id`, `email` (unique), `display_name`, `password_hash` (bcrypt), `status` (`active`/`disabled`), `is_superadmin`, `origin` (`operator`/`fixture`), `must_change_password`, `password_changed_at`, `last_login_at`, `disabled_at`, `disabled_by`, `account_kind` (`main`/`employee`), `sponsor_id` (Förderer eines Mitarbeiters; nur bei `employee`) | Konten mit `origin='fixture'` entfernt der Start in jeder Umgebung |
| `auth_sessions` | `id`, `account_id`, `secret_hash` (SHA-256, unique), `csrf_token`, `scope_kind`, `scope_id`, `epoch`, `expires_at`, `revoked_at`, `last_seen_at`, `label` (kurzer Gerätehinweis) | der bestätigte Datenraum steht in der Session |
| `auth_invitations` | `email`, `room_id`, `token_hash`, `invited_by`, `expires_at`, `accepted_at`, `role`, `revoked_at` | 7 Tage gültig |
| `data_rooms` | `id`, `kind` (`personal`/`organization`), `name`, `status` (`active`/`archived`), `created_by` | persönlicher Raum: `id = account_id` |
+1
View File
@@ -94,6 +94,7 @@ Danach Abzug der jeweiligen Ausnahme.
- Breadcrumbs nennen nur lesbare Stationen. Bei mehreren lesbaren Aktenzuordnungen ohne gewählten Kontext erscheint keine Hauptakte.
- Betreiber- und Verwalterrolle verleihen kein Leserecht auf persönliche Inhalte.
- **Raumfreigabe** (Tabelle `room_shares`): Der Owner teilt eine Akte oder einen Vorgang mit beliebigen Datenräumen, in denen er Mitglied oder Verwalter ist. Der Heimatraum spielt dafür keine Rolle. Aktive Mitglieder eines aktiven Raums erhalten Rechte nach Rolle: Leser lesen, Mitglied und Verwalter lesen und bearbeiten, Weitergeben und Löschen nie (`ROOM_RIGHTS`, `room_default` in `policy.py`). Die Obergrenze der Freigabe (`access = read`) begrenzt auf Lesen. Mehrere Freigaben addieren sich, danach wirken Ausnahmen. Eine Personenausnahme (Grant mit `is_exception` auf eine Person, Kontext leer) nimmt eine Person aus. Elemente und Aufgaben ohne Akte oder Vorgang bleiben beim Owner. Die Rechte der Akte reichen in Vorgänge und Inhalte wie bisher; ein Vorgang kann einzeln geteilt werden, ohne dass die Akte sichtbar wird. Der Owner sieht seine Einträge unabhängig von Raum und Mitgliedschaft. Das Löschen von Akte und Vorgang verlangt Owner oder ausdrückliches Löschrecht, nicht mehr nur Bearbeiten (schließt R-01 des Reviews).
- Kontoarten: Ein Mitarbeiter-Konto legt keine Räume an und keine Inhalte im persönlichen Raum an; es arbeitet in den eingeladenen Räumen nach Raumrolle (`ensure_can_create`, `require_main_user`). Raum-Eigentümer und Einladende sind Hauptnutzer. Beschreibung in [BENUTZERVERWALTUNG.md](BENUTZERVERWALTUNG.md).
- Plattform- und Raumrollen (Betreiber, Verwalter, Mitglied, Leser) und ihre Schutzregeln beschreibt [BENUTZERVERWALTUNG.md](BENUTZERVERWALTUNG.md). Der Leser legt im Raum nichts an und erhält dort keine Bearbeiten- oder Freigeben-Grants; die Auswertung der Objektrechte bleibt unverändert.
- Ein Quellabruf prüft zuerst das Leserecht im Kontext. Danach wird nur der an der Referenz gebundene Zugang des Owners verwendet. Eine Suche ohne `connector_id` nimmt bei mehreren eigenen Instanzen nicht die zuletzt angelegte. Ein Empfänger erhält weder Zugangsdaten noch die übrigen Treffer des Owners. Ein Entzug gilt beim nächsten Abruf, weil jedes Lesen die Rechte erneut prüft.
+6
View File
@@ -442,6 +442,12 @@ Der Nutzer nennt folgende tatsächlich genutzte Felder. Schreibweisen sind als G
**Begründung und Auswirkungen:** Die Akte bleibt der Rechteanker (F-01, S-01); die Raumfreigabe ist eine zweite, dynamische Rechtequelle neben den Einzelfreigaben je Person. Der Heimatraum eines Eintrags ist nur noch Ablage und Mandantengrenze (Technische Spezifikation 4.1) und bestimmt keine Rechte. Bestehende Freigaben der ersten Fassung (Freigabe an den Heimatraum) wurden in Raumfreigaben übernommen; Einträge ohne Freigabe bleiben privat. Quellzugänge des Owners (Paperless, Mail) werden durch die Raumfreigabe nicht mitgegeben, sondern brauchen weiter die ausdrückliche Freigabe. Elemente und Aufgaben ohne Akte oder Vorgang bleiben beim Owner. Verlässt eine Person ein Team oder wird sie Leser, enden ihre Freigaben an dieses Team. Umsetzungsstand: [BENUTZERVERWALTUNG.md](../architecture/BENUTZERVERWALTUNG.md).
### R-02 – Betreiber, Hauptnutzer und Mitarbeiter: bestätigt am 22.10.2026
**Beschluss:** Der Nutzer bestätigt das SaaS-Zielbild. (1) Der **Betreiber** ist der Superadmin des Dienstes. Er verwaltet die Hauptnutzer, sieht alle Datenräume (Konten, Rollen, Zustand, keine Inhalte) und eine Übersicht aller Teammitglieder, um seiner Rechenschaftspflicht nachzukommen. (2) Ein **Hauptnutzer** erhält später über ein Subscription-Modell seinen eigenen Arbeitsbereich. Er hat einen privaten Raum und beliebig viele Team-Räume, ist deren Eigentümer, lädt Mitarbeiter ein und verwaltet sie und ihre Rechte je Raum. (3) Ein **Mitarbeiter** arbeitet nur in den Räumen, in die er eingeladen wurde, nach der zugewiesenen Rolle. Er legt keine Räume an und führt keinen eigenen privaten Arbeitsbereich. Eine Einladung erzeugt immer ein Mitarbeiter-Konto; vollwertig wird ein Konto nur durch den Betreiber. (4) Die Subscription begrenzt später die Zahl der Mitarbeiter je Hauptnutzer und gegebenenfalls je Raum.
**Begründung und Auswirkungen:** Ohne diese Trennung könnte jeder Raum-Verwalter unbegrenzt vollwertige Konten erzeugen, und der Betreiber hätte keinen Überblick. Umgesetzt sind Kontoart, Förderer, Mein Team, die Team-Übersicht des Betreibers und eine zentrale Prüfstelle für Grenzen ohne Tarife (`access/limits.py`). Offen und für das Sicherheits- und Tarifkonzept vorgesehen: Pläne und Zahlung, die Grenzen selbst, Quellzugänge von Mitarbeitern. Umsetzungsstand: [BENUTZERVERWALTUNG.md](../architecture/BENUTZERVERWALTUNG.md).
## 6. Fortschreibung
16.10.2026, Arbeitsstand 0.1: Recovery vollständig gelesen, Repository-Unterlagen gezielt abgeglichen, ursprüngliche Nutzernachrichten geprüft und Ergänzungen gesichert. Historische Baseline unverändert übernommen.
+3
View File
@@ -14,6 +14,7 @@ import { ConnectorConfig } from "./sources/connector-config.jsx";
import { Account, ForcedPasswordChange } from "./admin/Account.jsx";
import { AdminEvents } from "./admin/Admin.jsx";
import { InviteAccept } from "./admin/InviteAccept.jsx";
import { AdminTeam, Team } from "./admin/Team.jsx";
import { UserDetail, Users } from "./admin/Users.jsx";
import { Work } from "./pages/Work.jsx";
import { Settings } from "./pages/Settings.jsx";
@@ -144,6 +145,8 @@ export function App() {
<Route path="users" element={<Users />} />
<Route path="users/:id" element={<UserDetail />} />
<Route path="account" element={<Account />} />
<Route path="team" element={<Team />} />
<Route path="admin/team" element={<AdminTeam />} />
<Route path="admin/rooms" element={<Navigate to="/rooms" replace />} />
<Route path="admin/events" element={<AdminEvents />} />
<Route path="search" element={<Search />} />
+172
View File
@@ -0,0 +1,172 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, fetchBlob } from "../api.js";
import { ErrorNote } from "../pages/widgets.jsx";
import { accountKindLabel, formatWhen, personRoomsText } from "./admin-core.js";
import { OneTimeSecret } from "./widgets.jsx";
// "Mein Team": the people in the rooms of a main user. He manages the employees he invited.
export function Team() {
const [items, setItems] = useState(null);
const [error, setError] = useState("");
const [notice, setNotice] = useState("");
const [issued, setIssued] = useState(null);
const [confirm, setConfirm] = useState("");
async function load() {
const data = await api("/api/v1/team");
setItems(data.items);
}
useEffect(() => {
load().catch((err) => setError(err.message));
}, []);
async function run(action, message = "") {
setError("");
setNotice("");
setConfirm("");
try {
await action();
if (message) setNotice(message);
await load();
} catch (err) {
setError(err.message);
}
}
return (
<main className="page">
<header className="page-head">
<div>
<h1>Mein Team</h1>
<p className="muted">
Alle Personen in deinen Datenräumen. Rollen je Raum ändern und neue Mitarbeiter einladen kannst du unter{" "}
<Link to="/rooms">Datenräume</Link>. Mitarbeiter, die du eingeladen hast, verwaltest du hier.
</p>
</div>
</header>
<ErrorNote error={error} />
{notice ? <p className="notice" role="status">{notice}</p> : null}
{issued ? (
<OneTimeSecret
title={`Einmal-Passwort für ${issued.name}`}
value={issued.password}
hint="Alle Sitzungen der Person sind beendet. Beim nächsten Anmelden legt sie ein eigenes Passwort fest. Der Wert wird nicht wieder angezeigt."
onDone={() => setIssued(null)}
/>
) : null}
{items === null ? <p className="muted">Wird geladen …</p> : null}
{items && !items.length ? <p className="muted">In deinen Datenräumen sind noch keine weiteren Personen.</p> : null}
<ul className="index">
{(items || []).map((person) => (
<li key={person.id}>
<strong>{person.display_name}</strong>
<span>
{accountKindLabel(person.account_kind)}{person.status === "disabled" ? " · deaktiviert" : ""} · {person.email} · zuletzt angemeldet {formatWhen(person.last_login_at)}
</span>
<span>{person.rooms.length ? personRoomsText(person.rooms) : "Aktuell in keinem deiner Räume."}</span>
{person.mine ? (
<span className="row">
{person.status === "disabled" ? (
<button type="button" className="quiet" onClick={() => run(() => api(`/api/v1/team/${person.id}`, { method: "PATCH", body: { status: "active" } }), "Das Konto ist wieder aktiv.")}>
Aktivieren
</button>
) : (
<button type="button" className="quiet" onClick={() => run(() => api(`/api/v1/team/${person.id}`, { method: "PATCH", body: { status: "disabled" } }), "Das Konto ist deaktiviert.")}>
Deaktivieren
</button>
)}
<button
type="button"
className="quiet"
disabled={person.status === "disabled"}
onClick={() => run(async () => {
const result = await api(`/api/v1/team/${person.id}/password-reset`, { method: "POST" });
setIssued({ name: person.display_name, password: result.temporary_password });
})}
>
Passwort zurücksetzen
</button>
</span>
) : null}
{person.rooms.length ? (
confirm === person.id ? (
<span className="row">
<button type="button" className="danger" onClick={() => run(() => api(`/api/v1/team/${person.id}/memberships`, { method: "DELETE" }), "Die Person ist aus deinen Räumen entfernt.")}>
Wirklich aus allen meinen Räumen entfernen
</button>
<button type="button" className="quiet" onClick={() => setConfirm("")}>Abbrechen</button>
</span>
) : (
<button type="button" className="quiet" onClick={() => setConfirm(person.id)}>Aus allen meinen Räumen entfernen</button>
)
) : null}
</li>
))}
</ul>
</main>
);
}
// Operator overview of all teams: main users, their employees, rooms and roles. No content.
export function AdminTeam() {
const [items, setItems] = useState(null);
const [error, setError] = useState("");
useEffect(() => {
api("/api/v1/admin/team")
.then((data) => setItems(data.items))
.catch((err) => setError(err.message));
}, []);
async function download() {
setError("");
try {
const blob = await fetchBlob("/api/v1/admin/team?format=csv");
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "team-uebersicht.csv";
link.click();
URL.revokeObjectURL(url);
} catch (err) {
setError(err.message);
}
}
return (
<main className="page">
<header className="page-head">
<div>
<p className="muted"><Link to="/settings">Verwaltung</Link></p>
<h1>Team-Übersicht</h1>
<p className="muted">Hauptnutzer mit ihren Mitarbeitern, Räumen und Rollen. Der Betreiber sieht Konten und Rollen, keine Inhalte.</p>
</div>
<button type="button" className="quiet" onClick={download}>Als CSV laden</button>
</header>
<ErrorNote error={error} />
{items === null ? <p className="muted">Wird geladen …</p> : null}
{items && !items.length ? <p className="muted">Noch keine Mitarbeiter-Konten.</p> : null}
{(items || []).map((owner) => (
<section key={owner.id} className="card stack" aria-label={`Team von ${owner.display_name}`}>
<h2>{owner.display_name}</h2>
<p className="muted">{owner.email}{owner.status === "disabled" ? " · deaktiviert" : ""}</p>
{owner.employees.length ? (
<ul className="index">
{owner.employees.map((employee) => (
<li key={employee.id}>
<Link to={`/users/${employee.id}`}><strong>{employee.display_name}</strong></Link>
<span>{employee.email}{employee.status === "disabled" ? " · deaktiviert" : ""} · zuletzt angemeldet {formatWhen(employee.last_login_at)}</span>
<span>{employee.rooms.length ? personRoomsText(employee.rooms) : "In keinem Raum."}</span>
</li>
))}
</ul>
) : (
<p className="muted">Keine Mitarbeiter.</p>
)}
</section>
))}
</main>
);
}
+30 -5
View File
@@ -4,7 +4,7 @@ import { api, markDirty } from "../api.js";
import { Modal } from "../pages/Modal.jsx";
import { ErrorNote } from "../pages/widgets.jsx";
import { SessionContext } from "../session.js";
import { accountRole, accountState, formatWhen, roleLabel } from "./admin-core.js";
import { accountKindLabel, accountRole, accountState, formatWhen, roleLabel } from "./admin-core.js";
import { OneTimeSecret } from "./widgets.jsx";
export function Users() {
@@ -63,9 +63,9 @@ export function Users() {
<header className="page-head">
<div>
<h1>Nutzer</h1>
<p className="muted">Neue Konten legt der Betreiber an. Jedes Konto erhält einen eigenen persönlichen Datenraum.</p>
<p className="muted">Der Betreiber legt Hauptnutzer an und verwaltet sie. Mitarbeiter lädt der Hauptnutzer in seinen Datenräumen ein.</p>
</div>
<button type="button" onClick={() => { setError(""); setIssued(null); setOpen(true); }}>Nutzer anlegen</button>
<button type="button" onClick={() => { setError(""); setIssued(null); setOpen(true); }}>Hauptnutzer anlegen</button>
</header>
<ErrorNote error={open ? "" : error} />
{issued ? (
@@ -89,9 +89,10 @@ export function Users() {
const state = accountState(account);
return (
<Link key={account.id} to={`/users/${account.id}`} className="tile">
<span className="tile__kind">{accountRole(account)} · {state.label}</span>
<span className="tile__kind">{accountRole(account)} · {accountKindLabel(account.account_kind)} · {state.label}</span>
<strong>{account.display_name}</strong>
<span>{account.email}</span>
{account.sponsor_name ? <span>Mitarbeiter von {account.sponsor_name}</span> : null}
<span>Letzte Anmeldung: {formatWhen(account.last_login_at)}</span>
</Link>
);
@@ -176,7 +177,7 @@ export function UserDetail() {
<div>
<p className="muted"><Link to="/users">Nutzer</Link></p>
<h1>{account?.display_name || "Konto"}</h1>
{account ? <p className="muted">{account.email} · {accountRole(account)} · {accountState(account).label}</p> : null}
{account ? <p className="muted">{account.email} · {accountKindLabel(account.account_kind)} · {accountState(account).label}{account.sponsor_name ? ` · Mitarbeiter von ${account.sponsor_name}` : ""}</p> : null}
</div>
</header>
<ErrorNote error={error} />
@@ -206,6 +207,30 @@ export function UserDetail() {
<p className="muted">Letzte Anmeldung: {formatWhen(account.last_login_at)} · Aktive Sitzungen: {account.active_sessions}</p>
</section>
{account.account_kind === "employee" ? (
<section className="card stack" aria-label="Kontoart">
<h2>Mitarbeiter-Konto</h2>
<p className="muted">Dieses Konto arbeitet nur in Räumen, in die {account.sponsor_name || "ein Hauptnutzer"} es eingeladen hat. Vollwertig wird es nur durch den Betreiber.</p>
<div className="row">
<button type="button" className="quiet" onClick={() => run(() => patch({ account_kind: "main" }), "Das Konto ist jetzt ein Hauptnutzer. Die Person meldet sich neu an.")}>
Zum Hauptnutzer machen
</button>
</div>
</section>
) : account.employees?.length ? (
<section className="card stack" aria-label="Mitarbeiter">
<h2>Mitarbeiter</h2>
<ul className="index">
{account.employees.map((employee) => (
<li key={employee.id}>
<Link to={`/users/${employee.id}`}><strong>{employee.display_name}</strong></Link>
<span>{employee.email}{employee.status === "disabled" ? " · deaktiviert" : ""}</span>
</li>
))}
</ul>
</section>
) : null}
<section className="card stack" aria-label="Betreiberrolle">
<h2>Betreiberrolle</h2>
<p className="muted">Betreiber verwalten Konten und Räume. Sie erhalten dadurch keinen Zugriff auf Akten anderer.</p>
+22
View File
@@ -93,3 +93,25 @@ export function parseShareDrag(text, kind) {
export function shareTargets(rooms) {
return (rooms || []).filter((room) => room.kind === "organization" && (room.role === "member" || room.role === "manager"));
}
// Main user (full account) or employee (works in the rooms he was invited to).
export function accountKindLabel(kind) {
return kind === "employee" ? "Mitarbeiter" : "Hauptnutzer";
}
export function isEmployee(session) {
return session?.account?.account_kind === "employee";
}
// Rooms where the person may create entries. An employee has no personal workspace.
export function writableRooms(session) {
return (session?.rooms || []).filter((room) => {
if (room.kind === "personal") return !isEmployee(session);
return room.role === "member" || room.role === "manager";
});
}
export function personRoomsText(rooms) {
if (!rooms?.length) return "in keinem deiner Räume";
return rooms.map((room) => `${room.name} (${roleLabel(room.role)})`).join(", ");
}
+25
View File
@@ -1,7 +1,10 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
accountKindLabel,
accountState,
personRoomsText,
writableRooms,
parseShareDrag,
shareTargets,
exposureSummary,
@@ -97,3 +100,25 @@ test("only rooms where the person writes are drop targets", () => {
assert.deepEqual(shareTargets(rooms).map((room) => room.id), ["a", "b"]);
assert.deepEqual(shareTargets(undefined), []);
});
test("account kinds have German labels", () => {
assert.equal(accountKindLabel("employee"), "Mitarbeiter");
assert.equal(accountKindLabel("main"), "Hauptnutzer");
assert.equal(accountKindLabel(undefined), "Hauptnutzer");
});
test("an employee has no personal workspace to create entries in", () => {
const rooms = [
{ id: "p", kind: "personal", role: "owner" },
{ id: "a", kind: "organization", role: "member" },
{ id: "b", kind: "organization", role: "reader" },
];
assert.deepEqual(writableRooms({ account: { account_kind: "main" }, rooms }).map((r) => r.id), ["p", "a"]);
assert.deepEqual(writableRooms({ account: { account_kind: "employee" }, rooms }).map((r) => r.id), ["a"]);
assert.deepEqual(writableRooms(null), []);
});
test("the rooms of a person are listed with their roles", () => {
assert.equal(personRoomsText([]), "in keinem deiner Räume");
assert.equal(personRoomsText([{ name: "Kanzlei", role: "reader" }, { name: "Büro", role: "member" }]), "Kanzlei (Leser), Büro (Mitglied)");
});
+3 -2
View File
@@ -9,6 +9,7 @@ import { SourcePicker, moduleFor, sourceModules } from "../sources/registry.jsx"
import { ErrorNote, ShareBox } from "./widgets.jsx";
import { RoomShare } from "../admin/RoomShare.jsx";
import { ShareDropStrip } from "../admin/ShareDropStrip.jsx";
import { writableRooms } from "../admin/admin-core.js";
import { ContentBoard, DateField, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
import { ReadingPane } from "./ReadingPane.jsx";
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
@@ -18,7 +19,7 @@ export function CaseList() {
const { session } = useContext(SessionContext);
const [items, setItems] = useState([]);
const [title, setTitle] = useState("");
const [roomId, setRoomId] = useState(session.rooms[0]?.id || "");
const [roomId, setRoomId] = useState(writableRooms(session)[0]?.id || "");
const [roomFilter, setRoomFilter] = useState("");
const [error, setError] = useState("");
const [creating, setCreating] = useState(false);
@@ -92,7 +93,7 @@ export function CaseList() {
<label>
Datenraum
<select value={roomId} onChange={(event) => setRoomId(event.target.value)}>
{session.rooms.map((room) => (
{writableRooms(session).map((room) => (
<option key={room.id} value={room.id}>{room.name}</option>
))}
</select>
+2 -1
View File
@@ -15,6 +15,7 @@ import { NavIcon } from "./icons.jsx";
import { ExportPackage } from "./ExportPackage.jsx";
import { RoomShare } from "../admin/RoomShare.jsx";
import { ShareDropStrip } from "../admin/ShareDropStrip.jsx";
import { writableRooms } from "../admin/admin-core.js";
function pageContext(params) {
const kind = params.get("context_kind");
@@ -70,7 +71,7 @@ export function MatterList() {
setError("");
setPending(true);
try {
const matter = await api("/api/v1/matters", { method: "POST", body: { title, home_scope_id: session.scope.id } });
const matter = await api("/api/v1/matters", { method: "POST", body: { title, home_scope_id: writableRooms(session).find((room) => room.id === session.scope.id)?.id || writableRooms(session)[0]?.id || session.scope.id } });
markDirty(false);
setCreating(false);
navigate(`/matters/${matter.id}`);
+32 -17
View File
@@ -6,6 +6,7 @@ import {
exposureSummary,
formatWhen,
inviteLink,
isEmployee,
isPrivateRoom,
lastManagerIds,
roleLabel,
@@ -247,14 +248,23 @@ function RoomAdmin({ room, onRenamed, onArchived }) {
</form>
) : null}
<h3>Einladungen</h3>
<p className="muted">Für Personen ohne Konto. Du erhältst einen Link, den du selbst weitergibst. Er gilt 7 Tage und einmal.</p>
{link ? <OneTimeSecret title="Einladungslink" value={link} onDone={() => setLink("")} /> : null}
<form onSubmit={invite} className="inline">
<input type="email" value={inviteMail} onChange={(event) => { setInviteMail(event.target.value); markDirty(true); }} placeholder="E-Mail der eingeladenen Person" aria-label="E-Mail der eingeladenen Person" required />
<RoleSelect value={inviteRole} onChange={setInviteRole} label="Rolle der eingeladenen Person" />
<button type="submit">Einladung erstellen</button>
</form>
<h3>Mitarbeiter einladen</h3>
{room.is_owner ? (
<>
<p className="muted">
Die Person erhält ein Mitarbeiter-Konto und arbeitet nur in den Räumen, in die du sie einlädst, nach der gewählten Rolle.
Du erhältst einen Link, den du selbst weitergibst. Er gilt 7 Tage und einmal.
</p>
{link ? <OneTimeSecret title="Einladungslink" value={link} onDone={() => setLink("")} /> : null}
<form onSubmit={invite} className="inline">
<input type="email" value={inviteMail} onChange={(event) => { setInviteMail(event.target.value); markDirty(true); }} placeholder="E-Mail der eingeladenen Person" aria-label="E-Mail der eingeladenen Person" required />
<RoleSelect value={inviteRole} onChange={setInviteRole} label="Rolle der eingeladenen Person" />
<button type="submit">Einladung erstellen</button>
</form>
</>
) : (
<p className="muted">Neue Mitarbeiter lädt der Eigentümer des Raums ein. Du kannst bestehende Konten aufnehmen.</p>
)}
{invitations.length ? (
<ul className="index">
{invitations.map((item) => (
@@ -295,6 +305,7 @@ function roomLabel(room) {
export function Rooms() {
const { session, refresh } = useContext(SessionContext);
const employee = isEmployee(session);
const [name, setName] = useState("");
const [visibility, setVisibility] = useState("room");
const [archived, setArchived] = useState([]);
@@ -356,15 +367,19 @@ export function Rooms() {
</li>
))}
</ul>
<section className="card stack" aria-label="Datenraum anlegen">
<h2>Neuen Datenraum anlegen</h2>
<form onSubmit={create} className="inline">
<input value={name} onChange={(event) => { setName(event.target.value); markDirty(true); }} placeholder="Name des neuen Datenraums" aria-label="Name des neuen Datenraums" required />
<VisibilitySelect value={visibility} onChange={setVisibility} />
<button type="submit">Datenraum anlegen</button>
</form>
<p className="muted">Du wirst Eigentümer und Verwalter. Der Raum ist privat, bis du Personen aufnimmst.</p>
</section>
{employee ? (
<p className="muted">Du arbeitest als Mitarbeiter in den Räumen, in die du eingeladen wurdest. Eigene Datenräume legt der Hauptnutzer an.</p>
) : (
<section className="card stack" aria-label="Datenraum anlegen">
<h2>Neuen Datenraum anlegen</h2>
<form onSubmit={create} className="inline">
<input value={name} onChange={(event) => { setName(event.target.value); markDirty(true); }} placeholder="Name des neuen Datenraums" aria-label="Name des neuen Datenraums" required />
<VisibilitySelect value={visibility} onChange={setVisibility} />
<button type="submit">Datenraum anlegen</button>
</form>
<p className="muted">Du wirst Eigentümer und Verwalter. Der Raum ist privat, bis du Personen aufnimmst.</p>
</section>
)}
{archived.length ? (
<section className="card stack" aria-label="Archivierte Datenräume">
<h2>Archivierte Datenräume</h2>
+12
View File
@@ -23,6 +23,13 @@ export function Settings() {
<strong>Quellen</strong>
<span>Paperless und E-Mail</span>
</Link>
{session?.account?.account_kind !== "employee" ? (
<Link className="tile" to="/team">
<span className="tile__kind">Verwaltung</span>
<strong>Mein Team</strong>
<span>Mitarbeiter und ihre Räume</span>
</Link>
) : null}
<Link className="tile" to="/account">
<span className="tile__kind">Verwaltung</span>
<strong>Mein Konto</strong>
@@ -35,6 +42,11 @@ export function Settings() {
<strong>Nutzer</strong>
<span>Konten, Rollen, Zugang</span>
</Link>
<Link className="tile" to="/admin/team">
<span className="tile__kind">Betreiber</span>
<strong>Team-Übersicht</strong>
<span>Hauptnutzer, Mitarbeiter, Räume</span>
</Link>
<Link className="tile" to="/admin/events">
<span className="tile__kind">Betreiber</span>
<strong>Verwaltungsprotokoll</strong>