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:
parent
1860118876
commit
3db2946d07
1 changed files with 3 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue