Ticket #20705: 20705-initial.diff

File 20705-initial.diff, 1.9 KB (added by Tim Graham, 9 years ago)
  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    index 050fc19..5722ec6 100644
    a b class AuthenticationForm(forms.Form):  
    196196
    197197class PasswordResetForm(forms.Form):
    198198    email = forms.EmailField(label=_("Email"), max_length=254)
     199    # The user attibute that stores the email address.
     200    EMAIL_FIELD = 'email'
    199201
    200202    def send_mail(self, subject_template_name, email_template_name,
    201203                  context, from_email, to_email, html_email_template_name=None):
    class PasswordResetForm(forms.Form):  
    220222        This allows subclasses to more easily customize the default policies
    221223        that prevent inactive users and users with unusable passwords from
    222224        resetting their password.
    223 
    224225        """
    225         active_users = get_user_model()._default_manager.filter(
    226             email__iexact=email, is_active=True)
     226        active_users = get_user_model()._default_manager.filter(**{
     227            '%s__iexact' % EMAIL_FIELD: mail,
     228            'is_active': True,
     229        })
    227230        return (u for u in active_users if u.has_usable_password())
    228231
    229232    def save(self, domain_override=None,
    class PasswordResetForm(forms.Form):  
    244247            else:
    245248                site_name = domain = domain_override
    246249            context = {
    247                 'email': user.email,
     250                'email': email,
    248251                'domain': domain,
    249252                'site_name': site_name,
    250253                'uid': urlsafe_base64_encode(force_bytes(user.pk)),
    class PasswordResetForm(forms.Form):  
    254257            }
    255258
    256259            self.send_mail(subject_template_name, email_template_name,
    257                            context, from_email, user.email,
     260                           context, from_email, email,
    258261                           html_email_template_name=html_email_template_name)
    259262
    260263
Back to Top