feat: private session history, own-permissions view, plug-gated start button

- non-admins now see ONLY their own sessions in /api/sessions (own app
  starts + own linked cards); gun scopes grant control, not visibility;
  admins see everything
- Account page shows the logged-in user's permissions in plain words
  (Administrator badge, or the guns/relays they control), built solely
  from data already visible to them
- Start button arms only when the gun reports Preparing (cable in the
  car); idle unplugged gun shows an explanatory hint instead
- keep owner's app rename to 'Art IoT'
- smoke test: 59 checks (gun-scoped user sees no foreign sessions)
This commit is contained in:
2026-07-12 09:04:06 +02:00
parent 3387f8689e
commit 069d544bb5
12 changed files with 98 additions and 17 deletions
+6 -4
View File
@@ -221,10 +221,12 @@ async def charger_probe(cp: Optional[str] = None, user: dict = Depends(current_u
# ---- session history: who charged when and how many kWh ----
def _may_see_session(user: dict, s: dict) -> bool:
"""Own sessions (own app starts or own cards), sessions on guns you
control, or everything for admin. Card ownership is looked up live, so
linking a card to a user retroactively shows them its history."""
if users.allowed(user["scopes"], f"charger:{s['cp']}:{s['connector']}"):
"""Transactions are private: admins see everything, everyone else sees
ONLY their own sessions (their app starts + their linked cards). Card
ownership is looked up live, so linking a card to a user retroactively
shows them its history. (Gun scopes grant CONTROL, not visibility —
owner decision 2026-07-12.)"""
if users.allowed(user["scopes"], "admin"):
return True
if s["id_tag"] == user.get("id_tag"):
return True