Opened 15 years ago

Closed 15 years ago

#12372 closed (wontfix)

passing ip to django.contrib.auth.views.password_reset email template

Reported by: Tim Miller Owned by: nobody
Component: contrib.auth Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It's pretty much a standard that all password reset verification emails contain the IP address of the person requesting the reset but I couldn't find a simple way to pass request to the email template used with django.contrib.auth.views.password_reset.

urls.py:

urlpatterns = patterns('django.contrib.auth',
    (r'^reset/$', 'views.password_reset', {
        'template_name': 'users/reset/form.html',
        'email_template_name': 'users/reset/email.html',
        'post_reset_redirect': 'done/',
    }),
)

Enabling django.core.context_processors.request in my settings let me reference request within form.html but not within the email.html template. I raised the issue in this thread on django-users and Daniel Roseman pointed out that the email sending and creation is done in the save method of the PasswordResetForm and request does not get passed.

A patch is attached which successfully allowed me to reference request.META.REMOTE_ADDR in the email template but at the moment I'm fairly clueless when it comes to the django internals so I'd appreciate advice.

Attachments (1)

request-email.diff (2.4 KB ) - added by Tim Miller 15 years ago.

Download all attachments as: .zip

Change History (2)

by Tim Miller, 15 years ago

Attachment: request-email.diff added

comment:1 by Luke Plant, 15 years ago

Resolution: wontfix
Status: newclosed

I'm unconvinced that this is 'standard' - in the dozens of password reset e-mails I've just checked on my computer from the past 5 or 6 years, only two included IP address information, and none of the big players like Google, Paypal etc. I certainly would never include it myself, because most users are not going to be able to do anything with that information. I'd classify it as 'unusual', not 'standard'.

Backwards compatibility is also tricky. At the very least, your patch would need to use something like options['request'] = request rather than the current positional argument. But that would still leave the problem of custom PasswordResetForm implementations which do not have the request keyword argument (quite likely if they have followed the signature provided by Django). These would throw an error if they were passed one.

Given the backwards incompatibility, and the dubious usefulness of this addition, I'm closing WONTFIX. (It is possible to work around the backward incompatibility by using function signature introspection, but it's a complicated addition which does not seem to be worth it for this use case). You will have to provide your own view function as well as your own Form, sorry.

Note: See TracTickets for help on using tickets.
Back to Top