Skip to content

Commit

Permalink
tweak permissions for 400 error code
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Dec 13, 2024
1 parent a024264 commit 5cc90b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/requests/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_framework import permissions as drf_permissions
from rest_framework import exceptions, permissions as drf_permissions

from api.base.utils import get_user_auth
from osf.models import (
Expand Down Expand Up @@ -71,12 +71,12 @@ def has_permission(self, request, view):

institution_id = request.data.get('institution')
if not institution_id:
return False
raise exceptions.ValidationError({'institution': 'Institution is required.'})

try:
institution = Institution.objects.get(_id=institution_id)
except Institution.DoesNotExist:
return False
raise exceptions.ValidationError({'institution': 'Institution is does not exist.'})

return get_user_auth(request).user.is_institutional_admin(institution)

Expand Down

0 comments on commit 5cc90b9

Please sign in to comment.