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

Commit

Permalink
aanpassen routes om nieuwe logic files te gebruiken
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarraga committed Mar 4, 2024
1 parent 3f635e7 commit 422c17b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/routes/projects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import APIRouter, HTTPException

from db.errors.database_errors import ItemNotFoundError
from domain.logic.SubjectLogic import is_user_authorized_for_subject
from domain.models.ProjectDataclass import ProjectDataclass
from routes.db import get_dao_provider
from routes.login import get_authenticated_user
Expand Down Expand Up @@ -36,6 +37,6 @@ def get_project(project_id: int) -> ProjectDataclass:
except ItemNotFoundError as err:
raise HTTPException(status_code=404) from err
subject = subject_dao.get(project.subject_id)
if not subject.is_user_authorized(user, get_dao_provider()):
if not is_user_authorized_for_subject(subject, user, get_dao_provider()):
raise HTTPException(status_code=403)
return project
3 changes: 2 additions & 1 deletion backend/routes/subjects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import APIRouter, HTTPException

from db.errors.database_errors import ItemNotFoundError
from domain.logic.SubjectLogic import is_user_authorized_for_subject
from domain.models.ProjectDataclass import ProjectDataclass
from domain.models.SubjectDataclass import SubjectDataclass
from routes.db import get_dao_provider
Expand Down Expand Up @@ -36,7 +37,7 @@ def get_subject_projects(subject_id: int) -> list[ProjectDataclass]:
project_dao = get_dao_provider().get_project_dao()
try:
subject = subject_dao.get(subject_id)
if not subject.is_user_authorized(get_authenticated_user(), get_dao_provider()):
if not is_user_authorized_for_subject(subject, get_authenticated_user(), get_dao_provider()):
raise HTTPException(status_code=403)
return project_dao.get_projects_of_subject(subject_id)
except ItemNotFoundError as err:
Expand Down
3 changes: 2 additions & 1 deletion backend/routes/users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from fastapi import APIRouter, HTTPException

from db.errors.database_errors import ItemNotFoundError
from domain.models.APIUser import APIUser, convert_user
from domain.logic.UserLogic import convert_user
from domain.models.APIUser import APIUser
from routes.db import get_dao_provider
from routes.login import get_authenticated_user, is_user_admin

Expand Down

0 comments on commit 422c17b

Please sign in to comment.