1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-22 14:29:36 +02:00

Disable registration

This commit is contained in:
Sean Morley 2024-08-16 10:59:31 -04:00
parent a48b2bf752
commit fa35526cd1
3 changed files with 15 additions and 1 deletions

View file

@ -4,6 +4,7 @@ from django.contrib.auth import get_user_model
from adventures.models import Adventure
from users.forms import CustomAllAuthPasswordResetForm
from dj_rest_auth.serializers import PasswordResetSerializer
from rest_framework.exceptions import PermissionDenied
User = get_user_model()
@ -78,6 +79,11 @@ class RegisterSerializer(serializers.Serializer):
}
def save(self, request):
# Check if registration is disabled
if getattr(settings, 'DISABLE_REGISTRATION', False):
raise PermissionDenied("Registration is currently disabled.")
# If registration is not disabled, proceed with the original logic
adapter = get_adapter()
user = adapter.new_user(request)
self.cleaned_data = self.get_cleaned_data()