Enhance Tenant Context and Access Control Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Failing after 4m0s
Test Suite / playwright-tests (push) Failing after 3m41s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Failing after 4m0s
Test Suite / playwright-tests (push) Failing after 3m41s
- Introduced `email_verified` and `account_state` attributes in the `TenantContext` to improve user state management. - Updated the `resolve_tenant_context` function to dynamically fetch `email_verified` status from the database and determine `account_state` based on user roles and memberships. - Implemented `assert_min_account_state` checks across various endpoints to enforce access control based on user account status. - Incremented version to 1.1.0 in version.py to reflect these enhancements in tenant context management and access control.
This commit is contained in:
1 parent
7cfbca40bb
commit
30dc30c7aa
21 files changed
+1124
-22
No files matched your search
@@ -446,8 +446,9 @@ def increment_club_feature_usage(
|
||||
_run(c)
|
||||
|
||||
|
||||
def list_club_entitlements(cur, club_id: int) -> Dict[str, Any]:
|
||||
"""Alle aktiven Shinkan-Features mit effektivem Limit und Verbrauch (für API/UI)."""
|
||||
def list_club_entitlements(cur, club_id: int, *, conn=None) -> Dict[str, Any]:
|
||||
"""Alle aktiven Shinkan-Features mit effektivem Limit und Verbrauch (Liste, intern)."""
|
||||
db_conn = conn if conn is not None else cur.connection
|
||||
plan_id = get_effective_club_plan(cur, club_id)
|
||||
cur.execute(
|
||||
"""
|
||||
@@ -461,7 +462,7 @@ def list_club_entitlements(cur, club_id: int) -> Dict[str, Any]:
|
||||
features_out = []
|
||||
for row in rows:
|
||||
fid = row["id"]
|
||||
access = _check_club_impl(club_id, fid, cur.connection)
|
||||
access = _check_club_impl(club_id, fid, db_conn)
|
||||
features_out.append(
|
||||
{
|
||||
"id": fid,
|
||||
@@ -474,6 +475,32 @@ def list_club_entitlements(cur, club_id: int) -> Dict[str, Any]:
|
||||
"used": access.get("used"),
|
||||
"remaining": access.get("remaining"),
|
||||
"reason": access.get("reason"),
|
||||
"reset_at": access.get("reset_at"),
|
||||
}
|
||||
)
|
||||
return {"club_id": club_id, "plan_id": plan_id, "features": features_out}
|
||||
|
||||
|
||||
def club_features_map(cur, club_id: int, *, conn=None) -> Dict[str, Any]:
|
||||
"""Feature-Kontingente als Dict feature_id → Zustand (für /me/entitlements)."""
|
||||
raw = list_club_entitlements(cur, club_id, conn=conn)
|
||||
features_dict: Dict[str, Any] = {}
|
||||
for row in raw.get("features") or []:
|
||||
fid = row["id"]
|
||||
features_dict[fid] = {
|
||||
"name": row.get("name"),
|
||||
"category": row.get("category"),
|
||||
"limit_type": row.get("limit_type"),
|
||||
"reset_period": row.get("reset_period"),
|
||||
"allowed": row.get("allowed"),
|
||||
"limit": row.get("limit"),
|
||||
"used": row.get("used"),
|
||||
"remaining": row.get("remaining"),
|
||||
"reason": row.get("reason"),
|
||||
"reset_at": row.get("reset_at"),
|
||||
}
|
||||
return {
|
||||
"club_id": raw.get("club_id"),
|
||||
"plan_id": raw.get("plan_id"),
|
||||
"features": features_dict,
|
||||
}
|
||||
Reference in new issue
Block a user