mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-23 06:49:37 +02:00
Disable registration
This commit is contained in:
parent
a48b2bf752
commit
fa35526cd1
3 changed files with 15 additions and 1 deletions
|
@ -161,6 +161,8 @@ REST_AUTH = {
|
|||
'PASSWORD_RESET_SERIALIZER': 'users.serializers.MyPasswordResetSerializer'
|
||||
}
|
||||
|
||||
DISABLE_REGISTRATION = getenv('DISABLE_REGISTRATION', 'False') == 'True'
|
||||
|
||||
STORAGES = {
|
||||
"staticfiles": {
|
||||
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -92,7 +92,13 @@
|
|||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') {
|
||||
close();
|
||||
if (isImageFetcherOpen) {
|
||||
isImageFetcherOpen = false;
|
||||
} else if (isPointModalOpen) {
|
||||
isPointModalOpen = false;
|
||||
} else {
|
||||
close(); // Closes the main adventure modal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue