From 3db2946d07ad78799bf6bf0dff010589d3edc147 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 27 Oct 2021 18:47:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Return=20403=20instead=20of=2050?= =?UTF-8?q?0=20when=20creating=20as=20a=20non-logged=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/sophon/core/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/sophon/core/views.py b/backend/sophon/core/views.py index e7e7069..5c05cdd 100644 --- a/backend/sophon/core/views.py +++ b/backend/sophon/core/views.py @@ -202,6 +202,9 @@ class ResearchGroupViewSet(WriteSophonViewSet): return models.ResearchGroup.objects.order_by("slug").all() def hook_create(self, serializer) -> dict[str, t.Any]: + if self.request.user.is_anonymous: + raise HTTPException(status=403) + # Add the owner field to the serializer return { "owner": self.request.user,