Code

Opened 4 years ago

Closed 4 years ago

#12372 closed (wontfix)

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

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

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 lashni 4 years ago.

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by lashni

comment:1 Changed 4 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.