Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
everyone can see a subject #45
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarraga committed Mar 7, 2024
1 parent cdfeb91 commit 66b1bca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/routes/dependencies/role_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions backend/routes/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 66b1bca

Please sign in to comment.