Changing to a cleaner implementation to allow for empty email address

This commit is contained in:
Stephen Meier 2021-01-18 17:26:57 -05:00
parent 6dc2b5b767
commit 496508d473

View file

@ -1423,19 +1423,13 @@ def create_superuser():
"\nCreate a superuser below. The superuser is Account #1, the 'owner' "
"account of the server. Email is optional and can be empty.\n"
)
from os import environ
if ("EVENNIA_SUPERUSER_USERNAME" in environ) and ("EVENNIA_SUPERUSER_EMAIL" in environ):
username, email = environ["EVENNIA_SUPERUSER_USERNAME"], environ["EVENNIA_SUPERUSER_EMAIL"]
django.core.management.call_command("createsuperuser", "--noinput",
"--username=" + username,
"--email=" + email, interactive=False)
if "EVENNIA_SUPERUSER_PASSWORD" in environ:
password = environ["EVENNIA_SUPERUSER_PASSWORD"]
from evennia.accounts.models import AccountDB
u = AccountDB.objects.get(username=username)
u.set_password(password)
u.save()
if "EVENNIA_SUPERUSER_USERNAME" in environ:
from evennia.accounts.models import AccountDB
superuser = AccountDB.objects.create_superuser(os.environ.get('EVENNIA_SUPERUSER_USERNAME'),
os.environ.get('EVENNIA_SUPERUSER_EMAIL'),
os.environ.get('EVENNIA_SUPERUSER_PASSWORD'))
superuser.save()
else:
django.core.management.call_command("createsuperuser", interactive=True)