0001-warn-user-after-account-self-deletion-26910.patch
src/authentic2/registration_backend/views.py | ||
---|---|---|
389 | 389 |
return kwargs |
390 | 390 | |
391 | 391 |
def form_valid(self, form): |
392 |
utils.send_account_deletion_mail(self.request, self.request.user) |
|
392 | 393 |
models.DeletedUser.objects.delete_user(self.request.user) |
393 | 394 |
self.request.user.email += '#%d' % random.randint(1, 10000000) |
394 | 395 |
self.request.user.email_verified = False |
src/authentic2/templates/authentic2/account_delete_notification_body.html | ||
---|---|---|
1 |
{% load i18n %} |
|
2 |
<html> |
|
3 |
<body style="max-width: 90ex"> |
|
4 |
{% blocktrans %} |
|
5 |
<p>{{ full_name }},</p> |
|
6 |
<p>Your account on {{ site }} has been deleted. |
|
7 |
All related data will be deleted today. |
|
8 |
You cannot log in with it anymore.</p> |
|
9 |
{% endblocktrans %} |
|
10 |
</body> |
|
11 |
</html> |
src/authentic2/templates/authentic2/account_delete_notification_body.txt | ||
---|---|---|
1 |
{% load i18n %}{% autoescape off %}{% blocktrans %}{{ full_name }}, |
|
2 | ||
3 |
Your account on {{ site }} has been deleted. |
|
4 |
All related data will be deleted today. |
|
5 |
You cannot log in with it anymore. |
|
6 |
{% endblocktrans %}{% endautoescape %} |
src/authentic2/templates/authentic2/account_delete_notification_subject.txt | ||
---|---|---|
1 |
{% load i18n %}{% autoescape off %}{% trans "Account deletion request on" %} {{ site }}{% endautoescape %} |
src/authentic2/utils.py | ||
---|---|---|
698 | 698 |
registration_url) |
699 | 699 | |
700 | 700 | |
701 |
def send_account_deletion_mail(request, user): |
|
702 |
'''Send an account deletion notification mail to an user. |
|
703 | ||
704 |
Can raise an smtplib.SMTPException |
|
705 |
''' |
|
706 |
logger = logging.getLogger(__name__) |
|
707 |
context = { |
|
708 |
'full_name': user.get_full_name(), |
|
709 |
'site': request.get_host()} |
|
710 |
template_names = [ |
|
711 |
'authentic2/account_delete_notification_%s' % user.ou, |
|
712 |
'authentic2/account_delete_notification'] |
|
713 |
send_templated_mail(user.email, template_names, context, request=request) |
|
714 |
logger.info(u'account deletion mail sent to %s', user.email) |
|
715 | ||
716 | ||
701 | 717 |
def build_reset_password_url(user, request=None, next_url=None, set_random_password=True): |
702 | 718 |
'''Build a reset password URL''' |
703 | 719 |
from .compat import default_token_generator |
tests/test_views.py | ||
---|---|---|
20 | 20 |
page = page.form.submit('cancel').follow() |
21 | 21 | |
22 | 22 | |
23 |
def test_account_delete(app, simple_user): |
|
23 |
def test_account_delete(app, simple_user, mailoutbox):
|
|
24 | 24 |
assert simple_user.is_active |
25 |
assert not len(mailoutbox) |
|
25 | 26 |
page = login(app, simple_user, path=reverse('delete_account')) |
26 | 27 |
page.form.set('password', simple_user.username) |
27 | 28 |
# FIXME: webtest does not set the Referer header, so the logout page will always ask for |
28 | 29 |
# confirmation under tests |
29 | 30 |
response = page.form.submit(name='submit').follow() |
30 | 31 |
response = response.form.submit() |
32 |
assert len(mailoutbox) == 1 |
|
31 | 33 |
assert not User.objects.get(pk=simple_user.pk).is_active |
32 | 34 |
assert urlparse(response.location).path == '/' |
33 | 35 |
response = response.follow().follow() |
34 |
- |