#17431: Allow PasswordResetForm subclasses full control over email message to 
send
------------------------------+--------------------
     Reporter:  ejucovy       |      Owner:  nobody
         Type:  New feature   |     Status:  new
    Component:  contrib.auth  |    Version:  SVN
     Severity:  Normal        |   Keywords:
 Triage Stage:  Unreviewed    |  Has patch:  1
Easy pickings:  0             |      UI/UX:  0
------------------------------+--------------------
 The `django.contrib.auth.forms.PasswordResetForm` has logic to:

 1. Validate that an active user exists with the email address provided
 1. Generate an unguessable URL for the given user to reset his password
 using a timestamped token
 1. Construct an email with a link to that URL
 1. Send that email to the given user's email address

 The `.save()` method of the form class is responsible for three of these
 four tasks.  The `.save()` method includes parameters for overriding the
 subject, body, and `From:` address of the email to be sent.  However, it's
 sometimes necessary to have more control over the email that will be sent.
 These use cases could include:

 1. BCC'ing a site administrator with a copy of the email sent
 1. Setting a custom `Reply-To` like "password-reset-h...@example.com" that
 is distinct from the message's `From:` address
 1. Setting a `text/html` MIME type for the message, or using an
 `EmailMultiAlternatives` object to attach both text and HTML versions of
 the message

 For all of these use cases, the knobs currently provided are insufficient,
 and require copying over all the logic in the `.save()` method.

 The attached patch satisfies these use cases by allowing the user to
 subclass PasswordResetForm and override a `.construct_email()` method,
 whose job is to construct and return an `EmailMessage` to be sent by the
 `.save()` method.  The changes are fully backwards-compatible, and a test
 demonstrating the subclassing approach is provided.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17431>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to