updated admin page with more functionality, simplified burger menu and added many-to-many parent-child relationship
Build and Push Docker Image / build-and-push (pull_request) Successful in 59s
Python Code Quality / python-code-quality (pull_request) Successful in 10s
Python Test / python-test (pull_request) Successful in 17s

This commit is contained in:
Brian Bjarke Jensen
2025-11-10 22:58:52 +01:00
parent df28af880a
commit 402b5898bb
26 changed files with 952 additions and 564 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Access control utility functions for verifying resource ownership."""
from fastapi import HTTPException
from baby_monitor.repositories.child.sqlite_child import SQLiteChildRepository
def verify_child_access(
child_repo: SQLiteChildRepository, child_id: int, user_id: int
) -> None:
"""Verify that user has access to the child.
Args:
child_repo: Child repository instance
child_id: ID of the child to verify access for
user_id: ID of the user requesting access
Raises:
HTTPException: 404 if child not found, 403 if user is not a parent
"""
child = child_repo.get_by_id(child_id)
if not child:
raise HTTPException(status_code=404, detail="Child not found")
parent_ids = child_repo.get_parent_ids(child_id)
if user_id not in parent_ids:
raise HTTPException(status_code=403, detail="Access denied to this child")