diff --git a/backend/sophon/core/views.py b/backend/sophon/core/views.py index 74e0648..9a20695 100644 --- a/backend/sophon/core/views.py +++ b/backend/sophon/core/views.py @@ -262,6 +262,9 @@ class ResearchGroupViewSet(WriteSophonViewSet): """ group = models.ResearchGroup.objects.get(pk=pk) + if self.request.user.is_anonymous: + return Response(status=s.HTTP_401_UNAUTHORIZED) + # Raise an error if the group doesn't allow member joins if group.access != "OPEN": return Response(status=s.HTTP_403_FORBIDDEN) @@ -283,6 +286,9 @@ class ResearchGroupViewSet(WriteSophonViewSet): """ group = models.ResearchGroup.objects.get(pk=pk) + if self.request.user.is_anonymous: + return Response(status=s.HTTP_401_UNAUTHORIZED) + # Raise an error if the user is the owner of the group if self.request.user == group.owner: return Response(status=s.HTTP_403_FORBIDDEN)