add new vars of 2factor and send emails

This commit is contained in:
Cayo Puigdefabregas 2024-02-06 18:14:25 +01:00
parent 98ffdd0e3f
commit ddd25d0655
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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'))

View File

@ -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)