Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Permission organization authorization #901

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions connect/usecases/authorizations/delete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db.models import QuerySet
from rest_framework.exceptions import PermissionDenied
from connect.common.models import (
Organization,
User,
Expand Down Expand Up @@ -53,6 +54,8 @@ def delete_project_authorization(self, project: Project, user: User, role: int =
)

def delete_authorization(self, auth_dto: DeleteAuthorizationDTO):
if auth_dto.request_user:
request_user : User = RetrieveUserUseCase().get_user_by_email(email=auth_dto.request_user)

if auth_dto.user_email:
user: User = RetrieveUserUseCase().get_user_by_email(email=auth_dto.user_email)
Expand All @@ -61,6 +64,9 @@ def delete_authorization(self, auth_dto: DeleteAuthorizationDTO):

org: Organization = RetrieveOrganizationUseCase().get_organization_by_uuid(org_uuid=auth_dto.org_uuid)

if not org.authorizations.filter(user=request_user).exists():
raise PermissionDenied("User does not have permission to perform this action")

org_auth = org.authorizations.get(user=user)

projects_uuids: QuerySet = user.project_authorizations_user.filter(organization_authorization__organization=org).values_list("project", flat=True)
Expand Down
Loading