Skip to content

Commit

Permalink
Merge pull request #238 from awf-dbca/user-org-auth-fix
Browse files Browse the repository at this point in the history
User Organisation Access Fix
  • Loading branch information
xzzy authored Feb 19, 2024
2 parents 19d8235 + 4aa1bc5 commit aa6eccb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions wildlifecompliance/components/organisations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ def get_queryset(self):
if is_internal(self.request) or self.allow_external:
return Organisation.objects.all()
elif is_customer(self.request):
org_contacts = OrganisationContact.objects.filter(is_admin=True).filter(email=user.email)
user_admin_orgs = [org.organisation.id for org in org_contacts]
return Organisation.objects.filter(id__in=user_admin_orgs)
#org_contacts = OrganisationContact.objects.filter(is_admin=True).filter(email=user.email)
#user_admin_orgs = [org.organisation.id for org in org_contacts]
#return Organisation.objects.filter(id__in=user_admin_orgs)
return user.wildlifecompliance_organisations.all()
return Organisation.objects.none()

@detail_route(methods=['GET'])
Expand Down
4 changes: 2 additions & 2 deletions wildlifecompliance/components/organisations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
def can_manage_org(organisation, user):
from wildlifecompliance.components.organisations.models import UserDelegation
try:
UserDelegation.objects.get(organisation=organisation, user=user)
return True
UserDelegation.objects.get(organisation=organisation,user=user)
return can_admin_org(organisation, user)
except UserDelegation.DoesNotExist:
pass
if user.has_perm('wildlifecompliance.system_administrator'):
Expand Down

0 comments on commit aa6eccb

Please sign in to comment.