From aebf8daf08503e5261776cbfe47029e97263b892 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Fri, 8 Dec 2023 13:52:01 +0530 Subject: [PATCH] fix: user deactivation if instance admin and remove auto assigning of workspace and projects --- apiserver/plane/app/views/user.py | 4 +++ apiserver/plane/license/api/views/instance.py | 31 ------------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/apiserver/plane/app/views/user.py b/apiserver/plane/app/views/user.py index 85874f460..008780526 100644 --- a/apiserver/plane/app/views/user.py +++ b/apiserver/plane/app/views/user.py @@ -49,6 +49,10 @@ class UserEndpoint(BaseViewSet): # Check all workspace user is active user = self.get_object() + # Instance admin check + if InstanceAdmin.objects.filter(user=user).exists(): + return Response({"error": "You cannot deactivate your account since you are an instance admin"}, status=status.HTTP_400_BAD_REQUEST) + projects_to_deactivate = [] workspaces_to_deactivate = [] diff --git a/apiserver/plane/license/api/views/instance.py b/apiserver/plane/license/api/views/instance.py index 0e40b897f..c88b3b75f 100644 --- a/apiserver/plane/license/api/views/instance.py +++ b/apiserver/plane/license/api/views/instance.py @@ -221,37 +221,6 @@ class InstanceAdminSignInEndpoint(BaseAPIView): is_password_autoset=False, ) - # if the current user is not using captain then add the current all users to workspace and projects - if user.email != "captain@plane.so": - # Add the current user also as a workspace member and project memeber to all the workspaces and projects - captain = User.objects.filter(email="captain@plane.so") - # Workspace members - workspace_members = WorkspaceMember.objects.filter(member=captain) - WorkspaceMember.objects.bulk_create( - [ - WorkspaceMember( - workspace=member.workspace_id, - member=user, - role=member.role, - ) - for member in workspace_members - ], - batch_size=100, - ) - # project members - project_members = ProjectMember.objects.filter(member=captain) - ProjectMember.objects.bulk_create( - [ - ProjectMember( - workspace=member.workspace_id, - member=user, - role=member.role, - ) - for member in project_members - ], - batch_size=100, - ) - # settings last active for the user user.is_active = True user.last_active = timezone.now()