From ddd25d0655a11a20f65ba71176c38fd0dc11efbd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 6 Feb 2024 18:14:25 +0100 Subject: [PATCH] add new vars of 2factor and send emails --- idhub/email/views.py | 9 +++++---- idhub/views.py | 2 +- trustchain_idhub/settings.py | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/idhub/email/views.py b/idhub/email/views.py index f14e2a5..caa9370 100644 --- a/idhub/email/views.py +++ b/idhub/email/views.py @@ -57,12 +57,13 @@ class NotifyActivateUserByEmail: html_email = loader.render_to_string(self.html_email_template_name, context) email_message.attach_alternative(html_email, 'text/html') try: - if settings.DEVELOPMENT: - logger.warning(to_email) - logger.warning(body) + if settings.ENABLE_EMAIL: + email_message.send() return - email_message.send() + logger.warning(to_email) + logger.warning(body) + except Exception as err: logger.error(err) return diff --git a/idhub/views.py b/idhub/views.py index b161633..9adf9f4 100644 --- a/idhub/views.py +++ b/idhub/views.py @@ -56,7 +56,7 @@ class LoginView(auth_views.LoginView): # ) # cache.set("KEY_DIDS", encryption_key, None) cache.set("KEY_DIDS", sensitive_data_encryption_key, None) - if not settings.DEVELOPMENT: + if settings.AUTH2FACTOR: self.request.session["2fauth"] = str(uuid.uuid4()) return redirect(reverse_lazy('idhub:confirm_send_2f')) diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 6ab3b83..d243e55 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -31,7 +31,6 @@ SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=bool) -DEVELOPMENT = config('DEVELOPMENT', default=False, cast=bool) ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='', cast=Csv()) CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default='', cast=Csv()) @@ -226,3 +225,7 @@ LOGGING = { ORGANIZATION = config('ORGANIZATION', 'Pangea') SYNC_ORG_DEV = config('SYNC_ORG_DEV', 'y') ORG_FILE = config('ORG_FILE', 'examples/organizations.csv') +ENABLE_EMAIL = config('ENABLE_EMAIL', default=True, cast=bool) +CREATE_TEST_USERS = config('CREATE_TEST_USERS', default=False, cast=bool) +AUTH2FACTOR = config('AUTH2FACTOR', default=True, cast=bool) +