1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 04:49:37 +02:00

better signup disable

This commit is contained in:
Sean Morley 2024-08-16 12:21:43 -04:00
parent 80883202bc
commit 9f574c8505
9 changed files with 138 additions and 69 deletions

View file

@ -5,6 +5,7 @@ from rest_framework.permissions import IsAuthenticated
from .serializers import ChangeEmailSerializer
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
from django.conf import settings
class ChangeEmailView(APIView):
permission_classes = [IsAuthenticated]
@ -28,4 +29,16 @@ class ChangeEmailView(APIView):
user.emailaddress_set.create(email=new_email, primary=True, verified=False)
user.save()
return Response({"detail": "Email successfully changed."}, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class IsRegistrationDisabled(APIView):
@swagger_auto_schema(
responses={
200: openapi.Response('Registration is disabled'),
400: 'Bad Request'
},
operation_description="Check if registration is disabled."
)
def get(self, request):
return Response({"is_disabled": settings.DISABLE_REGISTRATION}, status=status.HTTP_200_OK)