From 66b1bcaae24cbc102945da717deffb30ee045591 Mon Sep 17 00:00:00 2001 From: Lukas Barragan Torres Date: Thu, 7 Mar 2024 16:54:04 +0100 Subject: [PATCH] everyone can see a subject #45 --- backend/routes/dependencies/role_dependencies.py | 2 +- backend/routes/subject.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/routes/dependencies/role_dependencies.py b/backend/routes/dependencies/role_dependencies.py index 9c3eeb23..abe7619c 100644 --- a/backend/routes/dependencies/role_dependencies.py +++ b/backend/routes/dependencies/role_dependencies.py @@ -43,7 +43,7 @@ def get_authenticated_student(session: Session = Depends(get_session)) -> Studen return get_student(session, user_id) -def is_user_authorized_for_subject(session: Session, subject_id: int) -> bool: +def is_user_authorized_for_subject(subject_id: int, session: Session = Depends(get_session)) -> bool: user_id = get_authenticated_user() if is_user_teacher(session, user_id): subjects_of_teacher: list[SubjectDataclass] = get_subjects_of_teacher(session, subject_id) diff --git a/backend/routes/subject.py b/backend/routes/subject.py index fdec830c..6a4396cc 100644 --- a/backend/routes/subject.py +++ b/backend/routes/subject.py @@ -7,14 +7,14 @@ from domain.models.ProjectDataclass import ProjectDataclass from domain.models.SubjectDataclass import SubjectDataclass from routes.dependencies.role_dependencies import ( - get_authenticated_student, + get_authenticated_user, is_user_authorized_for_subject, ) subject_router = APIRouter() -@subject_router.get("/subjects/{subject_id}", dependencies=[Depends(get_authenticated_student)]) +@subject_router.get("/subjects/{subject_id}", dependencies=[Depends(get_authenticated_user)]) def subject_get(subject_id: int, session: Session = Depends(get_session)) -> SubjectDataclass: return get_subject(session, subject_id)