From be2653a50feb67a4916ae795b2b2886a5afe5a90 Mon Sep 17 00:00:00 2001 From: pedro Date: Thu, 7 Mar 2024 11:13:26 +0100 Subject: [PATCH] refactor ADMIN_{EMAIL,PASSWORD} vars specify explicitly that they are only used on initial moment (when loading the initial_datas script) --- README.md | 4 ++-- idhub/management/commands/initial_datas.py | 4 ++-- trustchain_idhub/settings.py | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 30f13b8..38056d7 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ MEDIA_ROOT=/tmp/media/ # DATABASE_URL=postgres://link:to@database:port/idhub # Defines the admin user after running the initial_datas command -# Defaults to "admin@example.org" if no ADMIN_EMAIL is provided -# ADMIN_EMAIL="idhub_admin@pangea.org" +# Defaults to "admin@example.org" if no INITIAL_ADMIN_EMAIL is provided +# INITIAL_ADMIN_EMAIL="idhub_admin@pangea.org" # Configures a list of tuples containing names and email addresses of site administrators who should receive error notifications. ADMINS=[('Admin', 'admin@example.org')] diff --git a/idhub/management/commands/initial_datas.py b/idhub/management/commands/initial_datas.py index dfc0be8..b005dc3 100644 --- a/idhub/management/commands/initial_datas.py +++ b/idhub/management/commands/initial_datas.py @@ -21,8 +21,8 @@ class Command(BaseCommand): OIDC_ORGS = settings.OIDC_ORGS def handle(self, *args, **kwargs): - ADMIN_EMAIL = config('ADMIN_EMAIL', 'admin@example.org') - ADMIN_PASSWORD = config('ADMIN_PASSWORD', '1234') + ADMIN_EMAIL = settings.INITIAL_ADMIN_EMAIL + ADMIN_PASSWORD = settings.INITIAL_ADMIN_PASSWORD self.create_admin_users(ADMIN_EMAIL, ADMIN_PASSWORD) if settings.CREATE_TEST_USERS: diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 53e0f86..f2fdc51 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -42,6 +42,9 @@ assert DOMAIN in ALLOWED_HOSTS, "DOMAIN is not ALLOWED_HOST" CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default=f'https://{DOMAIN}', cast=Csv()) +INITIAL_ADMIN_EMAIL = config("INITIAL_ADMIN_EMAIL", default='admin@example.org') +INITIAL_ADMIN_PASSWORD = config("INITIAL_ADMIN_PASSWORD", default='1234') + DEFAULT_FROM_EMAIL = config( 'DEFAULT_FROM_EMAIL', default='webmaster@localhost')