Skip to content

Commit

Permalink
Fix current user owner check
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Dec 5, 2024
1 parent 46196fe commit 64c005e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions apps/project/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ class LeaveProject(ProjectScopeMixin, graphene.Mutation):
def mutate(cls, root, info, **kwargs):
project = info.context.active_project
serializer = UserProjectLeaveSerializer(data={}, context={'request': info.context.request})
if serializer.is_valid():
serializer.save()
return LeaveProject(ok=True, result=project)
return LeaveProject(ok=False, errors=serializer.errors)
if errors := mutation_is_not_valid(serializer):
return LeaveProject(errors=errors, ok=False)
serializer.save()
return LeaveProject(result=project, errors=None, ok=True)


class ProjectMutationType(
Expand Down
2 changes: 1 addition & 1 deletion apps/project/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ def validate(self, data):

if (
membership.filter(role=ProjectRole.get_owner_role()).count() == 1 and
membership.member == self.current_user
membership.filter(member=self.current_user)
):
raise serializers.ValidationError('Last owner of project can\'t leave')
return data
Expand Down

0 comments on commit 64c005e

Please sign in to comment.