0001-misc-send-password-reset-email-even-if-disabled-acco.patch
src/authentic2/forms/passwords.py | ||
---|---|---|
57 | 57 |
user, |
58 | 58 |
set_random_password=set_random_password, |
59 | 59 |
next_url=self.cleaned_data.get('next_url')) |
60 |
for user in users.filter(is_active=False): |
|
61 |
logger.info('password reset failed for user "%r": account is disabled', user) |
|
62 |
utils.send_templated_mail(user, ['authentic2/password_reset_refused']) |
|
60 | 63 |
if not users.exists(): |
61 | 64 |
logger.info(u'password reset request for "%s", no user found', email) |
62 | 65 |
ctx = {'registration_url': utils.make_url('registration_register', absolute=True)} |
src/authentic2/templates/authentic2/password_reset_refused_body.html | ||
---|---|---|
1 |
{% extends "emails/body_base.html" %} |
|
2 |
{% load i18n %} |
|
3 | ||
4 |
{% block content %} |
|
5 |
<p>{% trans "Hi," %}</p> |
|
6 | ||
7 |
<p>{% blocktrans trimmed with hostname=request.get_host %} |
|
8 |
You requested reset of your password on {{ hostname }}. Unfortunately, your account has been disabled on this server, thus your request can't succeed. |
|
9 |
{% endblocktrans %}</p> |
|
10 |
{% endblock %} |
src/authentic2/templates/authentic2/password_reset_refused_body.txt | ||
---|---|---|
1 |
{% extends "emails/body_base.txt" %} |
|
2 |
{% load i18n %} |
|
3 | ||
4 |
{% block content %}{% trans "Hi," %} |
|
5 |
{% blocktrans trimmed with hostname=request.get_host %} |
|
6 |
You requested reset of your password on {{ hostname }}. Unfortunately, your account has been disabled on this server, thus your request can't succeed. |
|
7 |
{% endblocktrans %} |
|
8 |
{% endblock %} |
src/authentic2/templates/authentic2/password_reset_refused_subject.txt | ||
---|---|---|
1 |
{% extends "emails/subject.txt" %} |
|
2 |
{% load i18n %} |
|
3 | ||
4 |
{% block email-subject %}{% blocktrans with hostname=request.get_host %}Your account on {{ hostname }} is disabled{% endblocktrans %}{% endblock %} |
tests/test_password_reset.py | ||
---|---|---|
135 | 135 |
for body in (mail.body, mail.alternatives[0][0]): |
136 | 136 |
assert 'no account was found associated with this address' in body |
137 | 137 |
assert 'http://testserver/accounts/register/' in body |
138 | ||
139 | ||
140 |
def test_send_password_reset_email_disabled_account(app, simple_user, mailoutbox): |
|
141 |
simple_user.is_active = False |
|
142 |
simple_user.save() |
|
143 | ||
144 |
url = reverse('password_reset') |
|
145 |
resp = app.get(url, status=200) |
|
146 |
resp.form.set('email', simple_user.email) |
|
147 |
resp = resp.form.submit() |
|
148 | ||
149 |
mail = mailoutbox[0] |
|
150 |
assert mail.subject == 'Your account on testserver is disabled' |
|
151 |
assert 'your account has been disabled on this server' in mail.body |
|
138 |
- |