Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
removed double checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Vucis committed Mar 13, 2024
1 parent aaeb5b1 commit 46bb24e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
5 changes: 1 addition & 4 deletions backend/project/endpoints/projects/project_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from project.models.project import Project
from project.utils.query_agent import query_by_id_from_model, delete_by_id_from_model, \
patch_by_id_from_model
from project.utils.authentication import login_required, authorize_teacher_or_project_admin, authorize_teacher_of_project, authorize_project_visible
from project.utils.authentication import authorize_teacher_or_project_admin, authorize_teacher_of_project, authorize_project_visible


API_URL = getenv('API_HOST')
Expand All @@ -25,7 +25,6 @@ class ProjectDetail(Resource):
for implementing get, delete and put methods
"""

@login_required
@authorize_project_visible
def get(self, project_id):
"""
Expand All @@ -40,7 +39,6 @@ def get(self, project_id):
project_id,
RESPONSE_URL)

@login_required
@authorize_teacher_or_project_admin
def patch(self, project_id):
"""
Expand All @@ -56,7 +54,6 @@ def patch(self, project_id):
request.json
)

@login_required
@authorize_teacher_of_project
def delete(self, project_id):
"""
Expand Down
4 changes: 1 addition & 3 deletions backend/project/endpoints/projects/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from project.models.project import Project
from project.utils.query_agent import query_selected_from_model, insert_into_model
from project.utils.authentication import login_required, authorize_teacher
from project.utils.authentication import authorize_teacher

from project.endpoints.projects.endpoint_parser import parse_project_params

Expand All @@ -25,7 +25,6 @@ class ProjectsEndpoint(Resource):
for implementing get method
"""

@login_required
@authorize_teacher
def get(self):
"""
Expand All @@ -42,7 +41,6 @@ def get(self):
filters=request.args
)

@login_required
@authorize_teacher
def post(self):
"""
Expand Down
8 changes: 3 additions & 5 deletions backend/project/endpoints/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from project import db
from project.models.user import User as userModel
from project.utils.authentication import login_required, authorize_teacher, authorize_user, not_allowed
from project.utils.authentication import login_required, authorize_user, not_allowed

users_bp = Blueprint("users", __name__)
users_api = Api(users_bp)
Expand Down Expand Up @@ -45,8 +45,7 @@ def get(self):
return {"message": "An error occurred while fetching the users",
"url": f"{API_URL}/users"}, 500

@login_required
@authorize_teacher
@not_allowed
def post(self):
"""
This function will respond to post requests made to /users.
Expand Down Expand Up @@ -137,8 +136,7 @@ def patch(self, user_id):
"url": f"{API_URL}/users"}, 500


@login_required
@authorize_user # TODO users mogen enkel zichzelf verwijderen
@authorize_user
def delete(self, user_id):
"""
This function will respond to DELETE requests made to /users/<user_id>.
Expand Down
2 changes: 1 addition & 1 deletion backend/project/utils/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ def wrap(*args, **kwargs):
if is_teacher_of_course(auth_user_id, course_id) or is_admin_of_course(auth_user_id, course_id):
return f(*args, **kwargs)
abort_with_message(403, "")
return wrap
return wrap

0 comments on commit 46bb24e

Please sign in to comment.