refactor(core): the core's owner filters go through userscope, each held by a second account

Tokens, notifications, quota, debug sessions and the reset-link burn filtered
their owner inline. Ten of the fifteen filters had no test that noticed one
going missing; each now has a test where another account's rows must not
count, show or change.
This commit is contained in:
2026-10-19 23:36:01 +02:00
parent 531eb2eef1
commit ad6ccbac05
11 changed files with 164 additions and 15 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ from fastapi import APIRouter, Depends, Query
from sqlalchemy import func, select
from sqlalchemy.orm import Session
from app.userscope import owned_by
from app import quota
from app.auth import admin_user, current_user
from app.db import get_db
@@ -27,7 +28,7 @@ def _sum(db: Session, *conds) -> int:
@router.get("/my-usage")
def my_usage(user: User = Depends(current_user), db: Session = Depends(get_db)) -> dict:
now = datetime.now(timezone.utc)
mine = QuotaEvent.user_id == user.id
mine = owned_by(QuotaEvent.user_id, user)
by_action = {
action: int(units)
for action, units in db.execute(