From a3e75df22894e58bd5d74a8c79fa88dc7a594c24 Mon Sep 17 00:00:00 2001 From: InspectorCaracal Date: Sat, 17 Dec 2022 14:06:18 -0700 Subject: [PATCH] registration setting --- evennia/commands/default/unloggedin.py | 9 ++++ evennia/settings_default.py | 2 + evennia/web/templates/website/_menu.html | 8 ++-- .../website/registration/register.html | 43 ++++++++++--------- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/evennia/commands/default/unloggedin.py b/evennia/commands/default/unloggedin.py index 16e1224ceb..e92a52f3f5 100644 --- a/evennia/commands/default/unloggedin.py +++ b/evennia/commands/default/unloggedin.py @@ -172,6 +172,15 @@ class CmdUnconnectedCreate(COMMAND_DEFAULT_CLASS): locks = "cmd:all()" arg_regex = r"\s.*?|$" + def at_pre_cmd(self): + """Verify that account creation is enabled.""" + if not settings.REGISTER_ENABLED: + # truthy return cancels the command + self.msg("Registration is currently disabled.") + return True + + return super().at_pre_cmd() + def func(self): """Do checks and create account""" diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 38f372255f..a6d8c626a4 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -34,6 +34,8 @@ SERVER_HOSTNAME = "localhost" # Lockdown mode will cut off the game from any external connections # and only allow connections from localhost. Requires a cold reboot. LOCKDOWN_MODE = False +# Enables new account registration +REGISTER_ENABLED = True # Activate telnet service TELNET_ENABLED = True # A list of ports the Evennia telnet server listens on Can be one or many. diff --git a/evennia/web/templates/website/_menu.html b/evennia/web/templates/website/_menu.html index cbf8c00812..72fe89de02 100644 --- a/evennia/web/templates/website/_menu.html +++ b/evennia/web/templates/website/_menu.html @@ -78,9 +78,11 @@ folder and edit it to add/remove links to the menu.
  • Log In
  • -
  • - Register -
  • + {% if register_enabled %} +
  • + Register +
  • + {% endif %} {% endif %} {% endblock %} diff --git a/evennia/web/templates/website/registration/register.html b/evennia/web/templates/website/registration/register.html index 5475d922be..f54d75054d 100644 --- a/evennia/web/templates/website/registration/register.html +++ b/evennia/web/templates/website/registration/register.html @@ -27,26 +27,29 @@ Register {% endif %} {% if not user.is_authenticated %} -
    - {% csrf_token %} - - {% for field in form %} -
    - {{ field.label_tag }} - {{ field | addclass:"form-control" }} - {% if field.help_text %} - {{ field.help_text|safe }} - {% endif %} -
    - {% endfor %} - -
    -
    - - -
    -
    - + {% if register_enabled %} +
    + {% csrf_token %} + + {% for field in form %} +
    + {{ field.label_tag }} + {{ field | addclass:"form-control" }} + {% if field.help_text %} + {{ field.help_text|safe }} + {% endif %} +
    + {% endfor %} + +
    +
    + + +
    +
    + {% else %} +

    Registration is currently disabled.

    + {% endif %} {% endif %}