Update login contribs to honor ACCOUNT_REGISTRATION_ENABLED. Resolve #3428

This commit is contained in:
Griatch 2024-02-25 17:54:11 +01:00
parent 015698d06f
commit 43e31abc8d
4 changed files with 18 additions and 10 deletions

View file

@ -24,6 +24,8 @@
(InspectorCaracal)
- [Fix][pull3434]: Adjust lunr search weights to void clashing of cmd-aliases over
keys which caused some help entries to shadow others (InspectorCaracal)
- Fix: Make `menu/email_login` contribs honor `NEW_ACCOUNT_REGISTRATION_ENABLED`
setting (Griatch)
- Doc fixes (InspectorCaracal, Griatch)
[new-ondemandhandler][https://www.evennia.com/docs/latest/Components/OnDemandHandler.html]

View file

@ -6,9 +6,8 @@ import datetime
import re
from codecs import lookup as codecs_lookup
from django.conf import settings
import evennia
from django.conf import settings
from evennia.commands.cmdhandler import CMD_LOGINSTART
from evennia.comms.models import ChannelDB
from evennia.utils import class_from_module, create, gametime, logger, utils

View file

@ -33,7 +33,6 @@ the module given by settings.CONNECTION_SCREEN_MODULE.
"""
from django.conf import settings
from evennia.accounts.models import AccountDB
from evennia.commands.cmdhandler import CMD_LOGINSTART
from evennia.commands.cmdset import CmdSet
@ -142,6 +141,15 @@ class CmdUnconnectedCreate(MuxCommand):
aliases = ["cre", "cr"]
locks = "cmd:all()"
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 parse(self):
"""
The parser must handle the multiple-word account

View file

@ -21,14 +21,9 @@ called automatically when a new user connects.
"""
from django.conf import settings
from evennia import CmdSet, Command, syscmdkeys
from evennia.utils.evmenu import EvMenu
from evennia.utils.utils import (
callables_from_module,
class_from_module,
random_string_from_module,
)
from evennia.utils.utils import callables_from_module, class_from_module, random_string_from_module
_CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
_GUEST_ENABLED = settings.GUEST_ENABLED
@ -90,6 +85,10 @@ def node_enter_username(caller, raw_text, **kwargs):
else:
new_user = False
if new_user and not settings.ACCOUNT_REGISTRATION_ENABLED:
caller.msg("Registration is currently disabled.")
return None
# pass username/new_user into next node as kwargs
return "node_enter_password", {"new_user": new_user, "username": username}