auth_fc: send email on registration (#65839)
This commit is contained in:
parent
59644444ef
commit
588fd61628
|
@ -0,0 +1,10 @@
|
|||
{% extends "emails/body_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<p>{% blocktrans %}Hi {{ user }},{% endblocktrans %}</p>
|
||||
|
||||
<p>{% trans "You have just created an account using FranceConnect." %}</p>
|
||||
|
||||
{% include "emails/button-link.html" with url=login_url label=_("Login now") %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
|||
{% extends "emails/body_base.txt" %}{% load i18n %}{% block content %}{% autoescape off %}{% blocktrans %}Hi {{ user }},{% endblocktrans %}
|
||||
|
||||
{% trans "You have just created an account using FranceConnect." %}
|
||||
|
||||
{% trans "You can login by clicking on the link below:" %}
|
||||
{{ login_url }}
|
||||
{% endautoescape %}{% endblock %}
|
|
@ -0,0 +1,4 @@
|
|||
{% extends "emails/subject.txt" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block email-subject %}{% trans "Account creation using FranceConnect" %}{% endblock %}
|
|
@ -482,6 +482,14 @@ class LoginOrLinkView(View):
|
|||
if created:
|
||||
logger.info('auth_fc: new account "%s" created with FranceConnect sub "%s"', user, sub)
|
||||
hooks.call_hooks('event', name='fc-create', user=user, sub=sub, request=request)
|
||||
utils_misc.send_templated_mail(
|
||||
user,
|
||||
template_names=['authentic2_auth_fc/registration_success'],
|
||||
context={
|
||||
'login_url': request.build_absolute_uri(settings.LOGIN_URL),
|
||||
},
|
||||
request=self.request,
|
||||
)
|
||||
# FC account creation does not rely on the registration_completion generic view.
|
||||
# Registration event has to be recorded here:
|
||||
request.journal.record('user.registration', user=user, how='france-connect')
|
||||
|
|
|
@ -104,7 +104,7 @@ def test_login_username_autofocus(settings, app, franceconnect):
|
|||
assert response.pyquery('#id_username').attr.autofocus is not None
|
||||
|
||||
|
||||
def test_create(settings, app, franceconnect, hooks, service):
|
||||
def test_create(settings, app, franceconnect, hooks, service, mailoutbox):
|
||||
# test direct creation
|
||||
set_service(app, service)
|
||||
response = app.get('/login/?next=/idp/')
|
||||
|
@ -122,6 +122,14 @@ def test_create(settings, app, franceconnect, hooks, service):
|
|||
Event.objects.filter(type__name='user.registration', user=user).which_references(service).count() == 1
|
||||
)
|
||||
|
||||
# check registration email
|
||||
assert len(mailoutbox) == 1
|
||||
assert mailoutbox[0].subject == 'Account creation using FranceConnect'
|
||||
for body in (mailoutbox[0].body, mailoutbox[0].alternatives[0][0]):
|
||||
assert 'Hi AnonymousUser,' in body
|
||||
assert 'You have just created an account using FranceConnect.' in body
|
||||
assert 'http://testserver/login/' in body
|
||||
|
||||
assert user.verified_attributes.first_name == 'Ÿuñe'
|
||||
assert user.verified_attributes.last_name == 'Frédérique'
|
||||
assert path(response.location) == '/idp/'
|
||||
|
|
Loading…
Reference in New Issue