Code clean up and check to make sure length of password is greater than 0

This commit is contained in:
Stephen Meier 2021-01-22 23:22:35 -05:00
parent ce279de7c3
commit 54ebbde3a7

View file

@ -1424,11 +1424,14 @@ def create_superuser():
"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_PASSWORD" in environ):
username = environ.get("EVENNIA_SUPERUSER_USERNAME")
email = environ.get("EVENNIA_SUPERUSER_EMAIL")
password = environ.get("EVENNIA_SUPERUSER_PASSWORD")
if (username is not None) and (password is not None) and len(password) > 0:
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 = AccountDB.objects.create_superuser(username, email, password)
superuser.save()
else:
django.core.management.call_command("createsuperuser", interactive=True)