Skip to content
Snippets Groups Projects
Verified Commit afc803dc authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Allow setting initial superuser credentials as setting

parent adc66e60
No related branches found
No related tags found
1 merge request!514Resolve "Allow defining inital admin credentials from outside"
Pipeline #6268 passed
......@@ -3,6 +3,7 @@
from datetime import date, datetime
from typing import Iterable, List, Optional, Sequence, Union
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group as DjangoGroup
from django.contrib.contenttypes.fields import GenericForeignKey
......@@ -288,9 +289,7 @@ class Person(ExtensibleModel):
# Ensure we have an admin user
user = get_user_model()
if not user.objects.filter(is_superuser=True).exists():
admin = user.objects.create_superuser(
username="admin", email="root@example.com", password="admin"
)
admin = user.objects.create_superuser(**settings.AUTH_INITIAL_SUPERUSER)
admin.save()
def auto_select_primary_group(
......
......@@ -255,6 +255,12 @@ AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
]
AUTH_INITIAL_SUPERUSER = {
"username": _settings.get("auth.superuser.username", "admin"),
"password": _settings.get("auth.superuser.password", "admin"),
"email": _settings.get("auth.superuser.email", "root@example.com"),
}
# Authentication backends are dynamically populated
AUTHENTICATION_BACKENDS = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment