From f237f480df3489565ca1a73a8ce025c04cc1648f Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sat, 24 Aug 2024 23:20:50 -0400 Subject: [PATCH] Custom registration disable message --- backend/server/main/settings.py | 1 + backend/server/users/views.py | 2 +- documentation/docs/Configuration/disable_registration.md | 2 ++ frontend/src/routes/signup/+page.server.ts | 3 ++- frontend/src/routes/signup/+page.svelte | 4 +--- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/server/main/settings.py b/backend/server/main/settings.py index 4d9e788..a885736 100644 --- a/backend/server/main/settings.py +++ b/backend/server/main/settings.py @@ -169,6 +169,7 @@ REST_AUTH = { } DISABLE_REGISTRATION = getenv('DISABLE_REGISTRATION', 'False') == 'True' +DISABLE_REGISTRATION_MESSAGE = getenv('DISABLE_REGISTRATION_MESSAGE', 'Registration is disabled. Please contact the administrator if you need an account.') STORAGES = { "staticfiles": { diff --git a/backend/server/users/views.py b/backend/server/users/views.py index 68e9c36..2c8021d 100644 --- a/backend/server/users/views.py +++ b/backend/server/users/views.py @@ -40,5 +40,5 @@ class IsRegistrationDisabled(APIView): operation_description="Check if registration is disabled." ) def get(self, request): - return Response({"is_disabled": settings.DISABLE_REGISTRATION}, status=status.HTTP_200_OK) + return Response({"is_disabled": settings.DISABLE_REGISTRATION, "message": settings.DISABLE_REGISTRATION_MESSAGE}, status=status.HTTP_200_OK) \ No newline at end of file diff --git a/documentation/docs/Configuration/disable_registration.md b/documentation/docs/Configuration/disable_registration.md index d3f79ff..5313476 100644 --- a/documentation/docs/Configuration/disable_registration.md +++ b/documentation/docs/Configuration/disable_registration.md @@ -9,4 +9,6 @@ To disable registration, you can set the following variable in your docker-compo ```yaml environment: - DISABLE_REGISTRATION=True + # OPTIONAL: Set the message to display when registration is disabled + - DISABLE_REGISTRATION_MESSAGE='Registration is disabled for this instance of AdventureLog.' ``` diff --git a/frontend/src/routes/signup/+page.server.ts b/frontend/src/routes/signup/+page.server.ts index bf49fa3..72c3ac6 100644 --- a/frontend/src/routes/signup/+page.server.ts +++ b/frontend/src/routes/signup/+page.server.ts @@ -13,7 +13,8 @@ export const load: PageServerLoad = async (event) => { console.log(is_disabled_json); if (is_disabled_json.is_disabled) { return { - is_disabled: true + is_disabled: true, + message: is_disabled_json.message }; } else { return { diff --git a/frontend/src/routes/signup/+page.svelte b/frontend/src/routes/signup/+page.svelte index 75a675b..9a7fe42 100644 --- a/frontend/src/routes/signup/+page.svelte +++ b/frontend/src/routes/signup/+page.svelte @@ -98,9 +98,7 @@

Signup is disabled for this server.

-

Please contact the server administrator if you think this is an error.

-
-

If you are the administrator, users can be registered via the admin site.

+

{data.message}

{#if errors.message}