mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: user deactivation if instance admin and remove auto assigning of workspace and projects
This commit is contained in:
parent
d4a4046cd3
commit
aebf8daf08
@ -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 = []
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user