0003-auth_fc-send-verification-link-upon-account-creation.patch
src/authentic2_auth_fc/templates/authentic2_auth_fc/registration_success_body.html | ||
---|---|---|
6 | 6 | |
7 | 7 |
<p>{% trans "You have just created an account using FranceConnect." %}</p> |
8 | 8 | |
9 |
{% include "emails/button-link.html" with url=login_url label=_("Login now") %} |
|
9 |
<p>{% trans "You can complete your account validation by clicking on the button below." %}</p> |
|
10 | ||
11 |
{% include "emails/button-link.html" with url=verification_link label=_("Complete your account validation") %} |
|
10 | 12 |
{% endblock %} |
src/authentic2_auth_fc/templates/authentic2_auth_fc/registration_success_body.txt | ||
---|---|---|
2 | 2 | |
3 | 3 |
{% trans "You have just created an account using FranceConnect." %} |
4 | 4 | |
5 |
{% trans "You can login by clicking on the link below:" %}
|
|
6 |
{{ login_url }}
|
|
5 |
{% trans "You can complete your account validation by clicking on the link below:" %}
|
|
6 |
{{ verification_link }}
|
|
7 | 7 |
{% endautoescape %}{% endblock %} |
src/authentic2_auth_fc/views.py | ||
---|---|---|
496 | 496 |
if created: |
497 | 497 |
logger.info('auth_fc: new account "%s" created with FranceConnect sub "%s"', user, sub) |
498 | 498 |
hooks.call_hooks('event', name='fc-create', user=user, sub=sub, request=request) |
499 | ||
500 |
token = models.FcEmailVerificationToken.create(user) |
|
501 |
verification_link = request.build_absolute_uri( |
|
502 |
reverse('fc-verification', kwargs={'token': token.value}) |
|
503 |
) |
|
499 | 504 |
utils_misc.send_templated_mail( |
500 | 505 |
user, |
501 | 506 |
template_names=['authentic2_auth_fc/registration_success'], |
502 | 507 |
context={ |
503 | 508 |
'user': user, |
504 |
'login_url': request.build_absolute_uri(settings.LOGIN_URL),
|
|
509 |
'verification_link': verification_link,
|
|
505 | 510 |
}, |
506 | 511 |
request=self.request, |
507 | 512 |
) |
513 |
token.sent = True |
|
514 |
token.save() |
|
515 |
messages.warning( |
|
516 |
request, |
|
517 |
_( |
|
518 |
'Your account has been created. Please complete your registration by ' |
|
519 |
'consulting the account validation link sent to you by email.' |
|
520 |
), |
|
521 |
) |
|
508 | 522 |
# FC account creation does not rely on the registration_completion generic view. |
509 | 523 |
# Registration event has to be recorded here: |
510 | 524 |
request.journal.record('user.registration', user=user, how='france-connect') |
tests/auth_fc/test_auth_fc.py | ||
---|---|---|
128 | 128 |
for body in (mailoutbox[0].body, mailoutbox[0].alternatives[0][0]): |
129 | 129 |
assert 'Hi Ÿuñe Frédérique,' in body |
130 | 130 |
assert 'You have just created an account using FranceConnect.' in body |
131 |
assert 'https://testserver/login/' in body
|
|
131 |
assert 'You can complete your account validation' in body
|
|
132 | 132 | |
133 | 133 |
assert user.verified_attributes.first_name == 'Ÿuñe' |
134 | 134 |
assert user.verified_attributes.last_name == 'Frédérique' |
... | ... | |
379 | 379 |
assert models.FcAccount.objects.count() == 1 |
380 | 380 |
cookie = decode_cookie(app.cookies['messages']) |
381 | 381 |
if isinstance(cookie, list): |
382 |
assert len(cookie) == 1 |
|
383 |
cookie = cookie[0].message |
|
382 |
assert len(cookie) == 2 |
|
383 |
assert 'Your account has been created. Please complete your registration' in cookie[0].message |
|
384 |
cookie = cookie[1].message |
|
384 | 385 |
assert 'The following fields are mandatory for account creation: Title' in cookie |
385 | 386 | |
386 | 387 | |
387 |
- |