Fakultas Ilmu Komputer UI

Commit eedf84a7 authored by Irwanto's avatar Irwanto
Browse files

[GREEN] Fixed creating account without auth to have no author

parent 2fd4c4e8
Pipeline #49463 failed with stages
in 5 minutes and 37 seconds
from django.core.mail import send_mail
from django.contrib.auth.models import User
from django.contrib.auth.models import AnonymousUser, User
from django.shortcuts import get_object_or_404
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import status, viewsets
......@@ -73,6 +73,9 @@ class AccountViewSet(viewsets.ModelViewSet):
)
user = User.objects.create_user(username=username, password=password)
if isinstance(self.request.user, AnonymousUser):
Account.objects.create(user=user, **serializer.validated_data)
else:
Account.objects.create(user=user, author=self.request.user.account, **serializer.validated_data)
return Response(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment