mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 19:55:18 +02:00
better signup disable
This commit is contained in:
parent
80883202bc
commit
9f574c8505
9 changed files with 138 additions and 69 deletions
|
@ -4,7 +4,7 @@ from django.views.generic import RedirectView, TemplateView
|
|||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from adventures import urls as adventures
|
||||
from users.views import ChangeEmailView
|
||||
from users.views import ChangeEmailView, IsRegistrationDisabled
|
||||
from .views import get_csrf_token
|
||||
from drf_yasg.views import get_schema_view
|
||||
|
||||
|
@ -21,6 +21,7 @@ urlpatterns = [
|
|||
path('api/', include('worldtravel.urls')),
|
||||
|
||||
path('auth/change-email/', ChangeEmailView.as_view(), name='change_email'),
|
||||
path('auth/is-registration-disabled/', IsRegistrationDisabled.as_view(), name='is_registration_disabled'),
|
||||
|
||||
path('csrf/', get_csrf_token, name='get_csrf_token'),
|
||||
re_path(r'^$', TemplateView.as_view(
|
||||
|
|
|
@ -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)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue