Skip to content

Commit 8f67ca6

Browse files
committed
Changed the password reset URL which is sent out in the password reset email
message to use https: instead of http:. This is generally a good idea, and also silences Google Chrome's phishing warning. Fixes issue ietf-tools#1204. This commit should have contained only changes to a template file; by mistake, changes to two django files were also committed here. That change has been undone in [6725]. - Legacy-Id: 6724 Note: SVN reference [6725] has been migrated to Git commit ca1a04f660aa0473bf8f3aadc7809d462ac4cac0
1 parent afb09a0 commit 8f67ca6

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

django/core/handlers/base.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def handle_uncaught_exception(self, request, resolver, exc_info):
176176
request_repr = "Request repr() unavailable"
177177
message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
178178
extra_emails = self._get_extra_emails(exc_info)
179-
mail_admins(subject, message, fail_silently=True, html_message=html, extra_emails=extra_emails)
179+
admin_emails = self._get_admin_emails(exc_info)
180+
mail_admins(subject, message, fail_silently=True, html_message=html, extra_emails=extra_emails, admin_emails=admin_emails)
180181
# If Http500 handler is not installed, re-raise last exception
181182
if resolver.urlconf_module is None:
182183
raise exc_info[1], None, exc_info[2]
@@ -200,6 +201,18 @@ def _get_extra_emails(self, exc_info=None):
200201
tb = tb.tb_next
201202
return admins
202203

204+
def _get_admin_emails(self, exc_info=None):
205+
"""Helper function to retrieve app-specific admin email overrides.
206+
Here we stop as soon as we've found a setting, since the purpose
207+
here is to be able to limit the distribution of email notifications
208+
for especially sensitive modules."""
209+
etype, value, tb = exc_info or sys.exc_info()
210+
while tb is not None:
211+
f = tb.tb_frame
212+
if "ADMIN_EMAILS" in f.f_globals:
213+
return f.f_globals["ADMIN_EMAILS"]
214+
return None
215+
203216
def apply_response_fixes(self, request, response):
204217
"""
205218
Applies each of the functions in self.response_fixes to the request and

django/core/mail/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def send_mass_mail(datatuple, fail_silently=False, auth_user=None,
8383
return connection.send_messages(messages)
8484

8585

86-
def mail_admins(subject, message, fail_silently=False, connection=None, html_message=None, extra_emails=[]):
86+
def mail_admins(subject, message, fail_silently=False, connection=None, html_message=None, extra_emails=[], admin_emails=None):
8787
"""Sends a message to the admins, as defined by the ADMINS setting."""
88-
if not (settings.ADMINS or extra_emails):
88+
if not (settings.ADMINS or extra_emails or admin_emails):
8989
return
90-
emails = set(list(settings.ADMINS) + extra_emails)
90+
emails = admin_emails if admin_emails else set(list(settings.ADMINS) + extra_emails)
9191
from django.core.mail import EmailMultiAlternatives
9292
msg = EmailMultiAlternatives(settings.EMAIL_SUBJECT_PREFIX + subject, message, settings.SERVER_EMAIL, [a[1] for a in emails])
9393
if html_message:

ietf/templates/registration/password_reset_email.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ at {{ domain }}. In order to set a new password for the
66
{{ username }} account, please go to the following link and
77
follow the instructions there:
88

9-
http://{{ domain }}{% url confirm_password_reset username today realm auth %}
9+
https://{{ domain }}{% url confirm_password_reset username today realm auth %}
1010

1111
This link will expire in {{ expire }} days.
1212

0 commit comments

Comments
 (0)