1
0
mirror of https://github.com/etesync/server synced 2024-11-22 08:48:07 +00:00

Invitations: error when trying to invite oneself.

This commit is contained in:
Tom Hacohen 2020-08-28 13:55:15 +03:00
parent 8593ab1357
commit 2327466113

View File

@ -568,6 +568,10 @@ class InvitationOutgoingViewSet(InvitationBaseViewSet):
except Collection.DoesNotExist:
raise Http404('Collection does not exist')
if request.user == serializer.validated_data.get('user'):
content = {'code': 'self_invite', 'detail': 'Inviting yourself is invalid'}
return Response(content, status=status.HTTP_400_BAD_REQUEST)
if not permissions.is_collection_admin(collection, request.user):
raise PermissionDenied('User is not an admin of this collection')