mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
Merge pull request #3061 from InspectorCaracal/register-setting
Add setting to enable/disable new user registration
This commit is contained in:
commit
c26657e1c7
7 changed files with 56 additions and 23 deletions
|
|
@ -2115,6 +2115,14 @@ class TestUnconnectedCommand(BaseEvenniaCommandTest):
|
|||
self.call(unloggedin.CmdUnconnectedInfo(), "", expected)
|
||||
del gametime.SERVER_START_TIME
|
||||
|
||||
@override_settings(NEW_ACCOUNT_REGISTRATION_ENABLED=False)
|
||||
def test_disabled_registration(self):
|
||||
self.call(
|
||||
unloggedin.CmdUnconnectedCreate(),
|
||||
"testacct testpass",
|
||||
"Registration is currently disabled.",
|
||||
)
|
||||
|
||||
|
||||
# Test syscommands
|
||||
|
||||
|
|
|
|||
|
|
@ -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.NEW_ACCOUNT_REGISTRATION_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"""
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ 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
|
||||
# Controls whether new account registration is available.
|
||||
# Set to False to lock down the registration page and the create account command.
|
||||
NEW_ACCOUNT_REGISTRATION_ENABLED = True
|
||||
# Activate telnet service
|
||||
TELNET_ENABLED = True
|
||||
# A list of ports the Evennia telnet server listens on Can be one or many.
|
||||
|
|
|
|||
|
|
@ -78,9 +78,11 @@ folder and edit it to add/remove links to the menu.
|
|||
<li>
|
||||
<a class="nav-link" href="{% url 'login' %}?next={{ request.path }}">Log In</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="nav-link" href="{% url 'register' %}">Register</a>
|
||||
</li>
|
||||
{% if register_enabled %}
|
||||
<li>
|
||||
<a class="nav-link" href="{% url 'register' %}">Register</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -27,26 +27,29 @@ Register
|
|||
{% endif %}
|
||||
|
||||
{% if not user.is_authenticated %}
|
||||
<form method="post" action="?">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
<div class="form-field my-3">
|
||||
{{ field.label_tag }}
|
||||
{{ field | addclass:"form-control" }}
|
||||
{% if field.help_text %}
|
||||
<small class="form-text text-muted">{{ field.help_text|safe }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<input class="form-control btn btn-outline-secondary" type="submit" value="Register" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if register_enabled %}
|
||||
<form method="post" action="?">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
<div class="form-field my-3">
|
||||
{{ field.label_tag }}
|
||||
{{ field | addclass:"form-control" }}
|
||||
{% if field.help_text %}
|
||||
<small class="form-text text-muted">{{ field.help_text|safe }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<input class="form-control btn btn-outline-secondary" type="submit" value="Register" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</div>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>Registration is currently disabled.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ GAME_SLOGAN = None
|
|||
SERVER_VERSION = None
|
||||
SERVER_HOSTNAME = None
|
||||
|
||||
REGISTER_ENABLED = None
|
||||
|
||||
TELNET_ENABLED = None
|
||||
TELNET_PORTS = None
|
||||
TELNET_SSL_ENABLED = None
|
||||
|
|
@ -50,6 +52,7 @@ def load_game_settings():
|
|||
|
||||
"""
|
||||
global GAME_NAME, GAME_SLOGAN, SERVER_VERSION, SERVER_HOSTNAME
|
||||
global REGISTER_ENABLED
|
||||
global TELNET_ENABLED, TELNET_PORTS
|
||||
global TELNET_SSL_ENABLED, TELNET_SSL_PORTS
|
||||
global SSH_ENABLED, SSH_PORTS
|
||||
|
|
@ -67,6 +70,8 @@ def load_game_settings():
|
|||
GAME_SLOGAN = SERVER_VERSION
|
||||
SERVER_HOSTNAME = settings.SERVER_HOSTNAME
|
||||
|
||||
REGISTER_ENABLED = settings.NEW_ACCOUNT_REGISTRATION_ENABLED
|
||||
|
||||
TELNET_ENABLED = settings.TELNET_ENABLED
|
||||
TELNET_PORTS = settings.TELNET_PORTS
|
||||
TELNET_SSL_ENABLED = settings.SSL_ENABLED
|
||||
|
|
@ -119,6 +124,7 @@ def general_context(request):
|
|||
"evennia_setupapps": GAME_SETUP,
|
||||
"evennia_connectapps": CONNECTIONS,
|
||||
"evennia_websiteapps": WEBSITE,
|
||||
"register_enabled": REGISTER_ENABLED,
|
||||
"telnet_enabled": TELNET_ENABLED,
|
||||
"telnet_ports": TELNET_PORTS,
|
||||
"telnet_ssl_enabled": TELNET_SSL_ENABLED,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class TestGeneralContext(TestCase):
|
|||
|
||||
@patch("evennia.web.utils.general_context.GAME_NAME", "test_name")
|
||||
@patch("evennia.web.utils.general_context.GAME_SLOGAN", "test_game_slogan")
|
||||
@patch("evennia.web.utils.general_context.REGISTER_ENABLED", "register_enabled_testvalue")
|
||||
@patch(
|
||||
"evennia.web.utils.general_context.WEBSOCKET_CLIENT_ENABLED",
|
||||
"websocket_client_enabled_testvalue",
|
||||
|
|
@ -37,6 +38,7 @@ class TestGeneralContext(TestCase):
|
|||
"evennia_setupapps": ["Permissions", "Config"],
|
||||
"evennia_connectapps": ["Irc"],
|
||||
"evennia_websiteapps": ["Flatpages", "News", "Sites"],
|
||||
"register_enabled": "register_enabled_testvalue",
|
||||
"webclient_enabled": "webclient_enabled_testvalue",
|
||||
"websocket_enabled": "websocket_client_enabled_testvalue",
|
||||
"websocket_port": "websocket_client_port_testvalue",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue