Skip to content

Commit

Permalink
fix(api): confirm HTTP method is allowed before permission check
Browse files Browse the repository at this point in the history
return HTTP/405 for logged in user ONLY!!

!44 #159
  • Loading branch information
jon-nfc committed Jul 29, 2024
1 parent 8d59462 commit 3a9e4b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/api/views/mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.exceptions import PermissionDenied
from django.forms import ValidationError

from rest_framework import exceptions
from rest_framework.permissions import DjangoObjectPermissions

from access.mixin import OrganizationMixin
Expand Down Expand Up @@ -28,12 +29,16 @@ def permission_check(self, request, view, obj=None) -> bool:

self.request = request

method = self.request._request.method.lower()

if method.upper() not in view.allowed_methods:

view.http_method_not_allowed(request._request)

if hasattr(view, 'queryset'):
if view.queryset.model._meta:
self.obj = view.queryset.model

method = self.request._request.method.lower()

object_organization = None

if method == 'get':
Expand Down

0 comments on commit 3a9e4b2

Please sign in to comment.