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)
|
self.call(unloggedin.CmdUnconnectedInfo(), "", expected)
|
||||||
del gametime.SERVER_START_TIME
|
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
|
# Test syscommands
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,15 @@ class CmdUnconnectedCreate(COMMAND_DEFAULT_CLASS):
|
||||||
locks = "cmd:all()"
|
locks = "cmd:all()"
|
||||||
arg_regex = r"\s.*?|$"
|
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):
|
def func(self):
|
||||||
"""Do checks and create account"""
|
"""Do checks and create account"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ SERVER_HOSTNAME = "localhost"
|
||||||
# Lockdown mode will cut off the game from any external connections
|
# Lockdown mode will cut off the game from any external connections
|
||||||
# and only allow connections from localhost. Requires a cold reboot.
|
# and only allow connections from localhost. Requires a cold reboot.
|
||||||
LOCKDOWN_MODE = False
|
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
|
# Activate telnet service
|
||||||
TELNET_ENABLED = True
|
TELNET_ENABLED = True
|
||||||
# A list of ports the Evennia telnet server listens on Can be one or many.
|
# A list of ports the Evennia telnet server listens on Can be one or many.
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,12 @@ folder and edit it to add/remove links to the menu.
|
||||||
<li>
|
<li>
|
||||||
<a class="nav-link" href="{% url 'login' %}?next={{ request.path }}">Log In</a>
|
<a class="nav-link" href="{% url 'login' %}?next={{ request.path }}">Log In</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if register_enabled %}
|
||||||
<li>
|
<li>
|
||||||
<a class="nav-link" href="{% url 'register' %}">Register</a>
|
<a class="nav-link" href="{% url 'register' %}">Register</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ Register
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not user.is_authenticated %}
|
{% if not user.is_authenticated %}
|
||||||
|
{% if register_enabled %}
|
||||||
<form method="post" action="?">
|
<form method="post" action="?">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
|
|
@ -46,7 +47,9 @@ Register
|
||||||
<input type="hidden" name="next" value="{{ next }}" />
|
<input type="hidden" name="next" value="{{ next }}" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<p>Registration is currently disabled.</p>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ GAME_SLOGAN = None
|
||||||
SERVER_VERSION = None
|
SERVER_VERSION = None
|
||||||
SERVER_HOSTNAME = None
|
SERVER_HOSTNAME = None
|
||||||
|
|
||||||
|
REGISTER_ENABLED = None
|
||||||
|
|
||||||
TELNET_ENABLED = None
|
TELNET_ENABLED = None
|
||||||
TELNET_PORTS = None
|
TELNET_PORTS = None
|
||||||
TELNET_SSL_ENABLED = None
|
TELNET_SSL_ENABLED = None
|
||||||
|
|
@ -50,6 +52,7 @@ def load_game_settings():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
global GAME_NAME, GAME_SLOGAN, SERVER_VERSION, SERVER_HOSTNAME
|
global GAME_NAME, GAME_SLOGAN, SERVER_VERSION, SERVER_HOSTNAME
|
||||||
|
global REGISTER_ENABLED
|
||||||
global TELNET_ENABLED, TELNET_PORTS
|
global TELNET_ENABLED, TELNET_PORTS
|
||||||
global TELNET_SSL_ENABLED, TELNET_SSL_PORTS
|
global TELNET_SSL_ENABLED, TELNET_SSL_PORTS
|
||||||
global SSH_ENABLED, SSH_PORTS
|
global SSH_ENABLED, SSH_PORTS
|
||||||
|
|
@ -67,6 +70,8 @@ def load_game_settings():
|
||||||
GAME_SLOGAN = SERVER_VERSION
|
GAME_SLOGAN = SERVER_VERSION
|
||||||
SERVER_HOSTNAME = settings.SERVER_HOSTNAME
|
SERVER_HOSTNAME = settings.SERVER_HOSTNAME
|
||||||
|
|
||||||
|
REGISTER_ENABLED = settings.NEW_ACCOUNT_REGISTRATION_ENABLED
|
||||||
|
|
||||||
TELNET_ENABLED = settings.TELNET_ENABLED
|
TELNET_ENABLED = settings.TELNET_ENABLED
|
||||||
TELNET_PORTS = settings.TELNET_PORTS
|
TELNET_PORTS = settings.TELNET_PORTS
|
||||||
TELNET_SSL_ENABLED = settings.SSL_ENABLED
|
TELNET_SSL_ENABLED = settings.SSL_ENABLED
|
||||||
|
|
@ -119,6 +124,7 @@ def general_context(request):
|
||||||
"evennia_setupapps": GAME_SETUP,
|
"evennia_setupapps": GAME_SETUP,
|
||||||
"evennia_connectapps": CONNECTIONS,
|
"evennia_connectapps": CONNECTIONS,
|
||||||
"evennia_websiteapps": WEBSITE,
|
"evennia_websiteapps": WEBSITE,
|
||||||
|
"register_enabled": REGISTER_ENABLED,
|
||||||
"telnet_enabled": TELNET_ENABLED,
|
"telnet_enabled": TELNET_ENABLED,
|
||||||
"telnet_ports": TELNET_PORTS,
|
"telnet_ports": TELNET_PORTS,
|
||||||
"telnet_ssl_enabled": TELNET_SSL_ENABLED,
|
"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_NAME", "test_name")
|
||||||
@patch("evennia.web.utils.general_context.GAME_SLOGAN", "test_game_slogan")
|
@patch("evennia.web.utils.general_context.GAME_SLOGAN", "test_game_slogan")
|
||||||
|
@patch("evennia.web.utils.general_context.REGISTER_ENABLED", "register_enabled_testvalue")
|
||||||
@patch(
|
@patch(
|
||||||
"evennia.web.utils.general_context.WEBSOCKET_CLIENT_ENABLED",
|
"evennia.web.utils.general_context.WEBSOCKET_CLIENT_ENABLED",
|
||||||
"websocket_client_enabled_testvalue",
|
"websocket_client_enabled_testvalue",
|
||||||
|
|
@ -37,6 +38,7 @@ class TestGeneralContext(TestCase):
|
||||||
"evennia_setupapps": ["Permissions", "Config"],
|
"evennia_setupapps": ["Permissions", "Config"],
|
||||||
"evennia_connectapps": ["Irc"],
|
"evennia_connectapps": ["Irc"],
|
||||||
"evennia_websiteapps": ["Flatpages", "News", "Sites"],
|
"evennia_websiteapps": ["Flatpages", "News", "Sites"],
|
||||||
|
"register_enabled": "register_enabled_testvalue",
|
||||||
"webclient_enabled": "webclient_enabled_testvalue",
|
"webclient_enabled": "webclient_enabled_testvalue",
|
||||||
"websocket_enabled": "websocket_client_enabled_testvalue",
|
"websocket_enabled": "websocket_client_enabled_testvalue",
|
||||||
"websocket_port": "websocket_client_port_testvalue",
|
"websocket_port": "websocket_client_port_testvalue",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue