From ad3f27ef3cff028a1c9be7c10551f013a53ee399 Mon Sep 17 00:00:00 2001
From: Thomas NOEL
Date: Wed, 11 Dec 2019 14:00:00 +0100
Subject: [PATCH] registration: show only email address in post-registration
message (#37923)
---
.../templates/registration/registration_complete.html | 2 +-
src/authentic2/views.py | 2 ++
tests/test_registration.py | 4 +++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/authentic2/templates/registration/registration_complete.html b/src/authentic2/templates/registration/registration_complete.html
index 56a87dcb9..7699d0a9b 100644
--- a/src/authentic2/templates/registration/registration_complete.html
+++ b/src/authentic2/templates/registration/registration_complete.html
@@ -27,7 +27,7 @@
{% blocktrans with from_email=from_email %}
- If you still have not received the instructions, add {{from_email}}
+ If you still have not received the instructions, add "{{from_email_address}}"
to your address book or authorized sender list, and then repeat the
registration process.
{% endblocktrans %}
diff --git a/src/authentic2/views.py b/src/authentic2/views.py
index ae2859ebe..8d6d7b7f0 100644
--- a/src/authentic2/views.py
+++ b/src/authentic2/views.py
@@ -15,6 +15,7 @@
# along with this program. If not, see .
import collections
+from email.utils import parseaddr
import logging
import random
import re
@@ -1153,6 +1154,7 @@ class RegistrationCompleteView(TemplateView):
def get_context_data(self, **kwargs):
kwargs['next_url'] = utils.select_next_url(self.request, settings.LOGIN_REDIRECT_URL)
kwargs['from_email'] = settings.DEFAULT_FROM_EMAIL
+ kwargs['from_email_address'] = parseaddr(settings.DEFAULT_FROM_EMAIL)[1]
return super(RegistrationCompleteView, self).get_context_data(
account_activation_days=settings.ACCOUNT_ACTIVATION_DAYS,
**kwargs)
diff --git a/tests/test_registration.py b/tests/test_registration.py
index 46c657d63..81c09293e 100644
--- a/tests/test_registration.py
+++ b/tests/test_registration.py
@@ -32,6 +32,7 @@ def test_registration(app, db, settings, mailoutbox, external_redirect):
settings.LANGUAGE_CODE = 'en-us'
settings.A2_VALIDATE_EMAIL_DOMAIN = can_resolve_dns()
+ settings.DEFAULT_FROM_EMAIL = 'show only addr '
# disable existing attributes
models.Attribute.objects.update(disabled=True)
@@ -55,7 +56,8 @@ def test_registration(app, db, settings, mailoutbox, external_redirect):
assert 'Follow the instructions' in response.text
assert 'testbot@entrouvert.com' in response.text
assert 'considered as spam' in response.text
- assert settings.DEFAULT_FROM_EMAIL in response.text
+ assert '"noreply@example.net"' in response.text
+ assert 'show only addr' not in response.text
assert len(mailoutbox) == 1
link = get_link_from_mail(mailoutbox[0])