forms: Fix accounts listed in password_reset email to active accounts.

Previously we were listing both accounts, active as well as non-active.
Fixes: #10130.
This commit is contained in:
Shubham Dhama
2018-08-04 17:37:54 +05:30
committed by Tim Abbott
parent ab22b4411f
commit 2dec30e4ab
3 changed files with 10 additions and 10 deletions

View File

@@ -7,19 +7,19 @@
on {{ realm_uri }}, but you do not have an on {{ realm_uri }}, but you do not have an
active account in {{ realm_uri }}. active account in {{ realm_uri }}.
{% if accounts %} {% if active_accounts %}
{% if multiple_accounts %} {% if multiple_active_accounts %}
However, you do have active accounts in the following However, you do have active accounts in the following
organizations. organizations.
<ul> <ul>
{% for account in accounts %} {% for active_account in active_accounts %}
<li>{{ account.realm.uri }}</li> <li>{{ active_accounts.realm.uri }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
You can try logging in or resetting your password in the organization You can try logging in or resetting your password in the organization
you want. you want.
{% else %} {% else %}
However, you do have an active account in the {{ accounts[0].realm.uri }} However, you do have an active account in the {{ active_accounts[0].realm.uri }}
organization; you can try logging in or resetting your password there. organization; you can try logging in or resetting your password there.
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@@ -8,4 +8,4 @@ ZULIP_VERSION = "1.8.1+git"
# Typically, adding a dependency only requires a minor version bump, and # Typically, adding a dependency only requires a minor version bump, and
# removing a dependency requires a major version bump. # removing a dependency requires a major version bump.
PROVISION_VERSION = '25.5' PROVISION_VERSION = '25.6'

View File

@@ -249,10 +249,10 @@ class ZulipPasswordResetForm(PasswordResetForm):
context=context) context=context)
else: else:
context['no_account_in_realm'] = True context['no_account_in_realm'] = True
accounts = UserProfile.objects.filter(email__iexact=email) active_accounts = UserProfile.objects.filter(email__iexact=email, is_active=True)
if accounts: if active_accounts:
context['accounts'] = accounts context['active_accounts'] = active_accounts
context['multiple_accounts'] = accounts.count() != 1 context['multiple_active_accounts'] = active_accounts.count() != 1
send_email('zerver/emails/password_reset', to_email=email, send_email('zerver/emails/password_reset', to_email=email,
from_name="Zulip Account Security", from_name="Zulip Account Security",
from_address=FromAddress.tokenized_no_reply_address(), from_address=FromAddress.tokenized_no_reply_address(),