1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +00:00

🐛 Return 403 instead of 500 when creating as a non-logged user

This commit is contained in:
Steffo 2021-10-27 18:47:54 +02:00
parent 1860118876
commit 3db2946d07

View file

@ -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,