From 491bd6d2c9a28443e4486921b71f83c7df051029 Mon Sep 17 00:00:00 2001
From: Shubham Dhama
Date: Wed, 15 Aug 2018 01:36:47 +0530
Subject: [PATCH] emails/password_reset: Refactor and replace
no_account_in_realm.
In place of no_account_in_realm we will use its negation
active_account_in_realm as a part of refactoring this template.
---
.../zerver/emails/password_reset.source.html | 24 ++++++++++---------
templates/zerver/emails/password_reset.txt | 14 +++++------
zerver/forms.py | 4 ++--
3 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/templates/zerver/emails/password_reset.source.html b/templates/zerver/emails/password_reset.source.html
index 3886bdfc07..d49edc3720 100644
--- a/templates/zerver/emails/password_reset.source.html
+++ b/templates/zerver/emails/password_reset.source.html
@@ -1,8 +1,14 @@
{% extends "zerver/emails/compiled/email_base_default.html" %}
{% block content %}
-
- {% if no_account_in_realm %}
+ {% if active_account_in_realm %}
+
+ Psst. Word on the street is that you need a new password, {{ email }}.
+ It's all good. Click here and we'll take care of the rest:
+ Reset password
+
+ {% else %}
+
Someone (possibly you) requested a password reset email for {{ email }}
on {{ realm_uri }}, but you do not have an
active account in {{ realm_uri }}.
@@ -23,14 +29,10 @@
organization; you can try logging in or resetting your password there.
{% endif %}
{% endif %}
- {% else %}
- Psst. Word on the street is that you need a new password, {{ email }}.
- It's all good. Click here and we'll take care of the rest:
- Reset password
+
{% endif %}
-
-
- Thanks,
- Your friends at Zulip HQ
-
+
+ Thanks,
+ Your friends at Zulip HQ
+
{% endblock %}
diff --git a/templates/zerver/emails/password_reset.txt b/templates/zerver/emails/password_reset.txt
index 9676207f48..0d500fad67 100644
--- a/templates/zerver/emails/password_reset.txt
+++ b/templates/zerver/emails/password_reset.txt
@@ -1,4 +1,10 @@
-{% if no_account_in_realm %}
+{% if active_account_in_realm %}
+Psst. Word on the street is that you need a new password, {{ email }}.
+
+It's all good. Follow the link below and we'll take care of the rest:
+
+{{ reset_url }}
+{% else %}
Someone (possibly you) requested a password reset email for
{{ email }} on {{ realm_uri }}, but
you do not have an active account in {{ realm_uri }}.
@@ -15,12 +21,6 @@ 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.
{% endif %}
{% endif %}
-{% else %}
-Psst. Word on the street is that you need a new password, {{ email }}.
-
-It's all good. Follow the link below and we'll take care of the rest:
-
-{{ reset_url }}
{% endif %}
Thanks,
diff --git a/zerver/forms.py b/zerver/forms.py
index fd90528e97..2e0d4e17d3 100644
--- a/zerver/forms.py
+++ b/zerver/forms.py
@@ -241,14 +241,14 @@ class ZulipPasswordResetForm(PasswordResetForm):
endpoint = reverse('django.contrib.auth.views.password_reset_confirm',
kwargs=dict(uidb64=uid, token=token))
- context['no_account_in_realm'] = False
+ context['active_account_in_realm'] = True
context['reset_url'] = "{}{}".format(user.realm.uri, endpoint)
send_email('zerver/emails/password_reset', to_user_id=user.id,
from_name="Zulip Account Security",
from_address=FromAddress.tokenized_no_reply_address(),
context=context)
else:
- context['no_account_in_realm'] = True
+ context['active_account_in_realm'] = False
active_accounts = UserProfile.objects.filter(email__iexact=email, is_active=True)
if active_accounts:
context['active_accounts'] = active_accounts