1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59: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

@ -161,6 +161,8 @@ REST_AUTH = {
'PASSWORD_RESET_SERIALIZER': 'users.serializers.MyPasswordResetSerializer' 'PASSWORD_RESET_SERIALIZER': 'users.serializers.MyPasswordResetSerializer'
} }
DISABLE_REGISTRATION = getenv('DISABLE_REGISTRATION', 'False') == 'True'
STORAGES = { STORAGES = {
"staticfiles": { "staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",

View file

@ -4,6 +4,7 @@ from django.contrib.auth import get_user_model
from adventures.models import Adventure from adventures.models import Adventure
from users.forms import CustomAllAuthPasswordResetForm from users.forms import CustomAllAuthPasswordResetForm
from dj_rest_auth.serializers import PasswordResetSerializer from dj_rest_auth.serializers import PasswordResetSerializer
from rest_framework.exceptions import PermissionDenied
User = get_user_model() User = get_user_model()
@ -78,6 +79,11 @@ class RegisterSerializer(serializers.Serializer):
} }
def save(self, request): 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() adapter = get_adapter()
user = adapter.new_user(request) user = adapter.new_user(request)
self.cleaned_data = self.get_cleaned_data() self.cleaned_data = self.get_cleaned_data()

View file

@ -92,7 +92,13 @@
function handleKeydown(event: KeyboardEvent) { function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') { if (event.key === 'Escape') {
close(); if (isImageFetcherOpen) {
isImageFetcherOpen = false;
} else if (isPointModalOpen) {
isPointModalOpen = false;
} else {
close(); // Closes the main adventure modal
}
} }
} }