diff --git a/src/models.py b/src/models.py index 196dc15..763af9f 100644 --- a/src/models.py +++ b/src/models.py @@ -34,6 +34,7 @@ class OrgResponse(BaseModel): license_type: str = "" created_at: str globe_access: bool = False + network_access: bool = False class LicenseCreate(BaseModel): @@ -63,6 +64,7 @@ class LicenseResponse(BaseModel): budget_warning_percent: Optional[int] = None created_at: str globe_access: bool = False + network_access: bool = False class UserCreate(BaseModel): @@ -81,3 +83,4 @@ class UserResponse(BaseModel): last_login_at: Optional[str] created_at: str globe_access: bool = False + network_access: bool = False diff --git a/src/routers/users.py b/src/routers/users.py index 791a322..455e886 100644 --- a/src/routers/users.py +++ b/src/routers/users.py @@ -180,3 +180,20 @@ async def delete_user( await db.execute("DELETE FROM users WHERE id = ?", (user_id,)) await db.commit() + + +@router.put("/{user_id}/network-access") +async def toggle_network_access( + user_id: int, + admin: dict = Depends(get_current_admin), + db: aiosqlite.Connection = Depends(db_dependency), +): + cursor = await db.execute("SELECT id, network_access FROM users WHERE id = ?", (user_id,)) + row = await cursor.fetchone() + if not row: + raise HTTPException(status_code=404, detail="Nutzer nicht gefunden") + + new_val = 0 if row[1] else 1 + await db.execute("UPDATE users SET network_access = ? WHERE id = ?", (new_val, user_id)) + await db.commit() + return {"ok": True, "network_access": bool(new_val)} diff --git a/src/static/dashboard.html b/src/static/dashboard.html index 9a72656..a629e83 100644 --- a/src/static/dashboard.html +++ b/src/static/dashboard.html @@ -108,6 +108,7 @@