Ticket #11300: 11300.diff
File 11300.diff, 3.7 KB (added by , 15 years ago) |
---|
-
django/contrib/auth/forms.py
111 111 return email 112 112 113 113 def save(self, domain_override=None, email_template_name='registration/password_reset_email.html', 114 use_https=False, token_generator=default_token_generator ):114 use_https=False, token_generator=default_token_generator, from_email=None): 115 115 """ 116 116 Generates a one-use only link for resetting password and sends to the user 117 117 """ … … 134 134 'protocol': use_https and 'https' or 'http', 135 135 } 136 136 send_mail(_("Password reset on %s") % site_name, 137 t.render(Context(c)), None, [user.email])137 t.render(Context(c)), from_email, [user.email]) 138 138 139 139 class SetPasswordForm(forms.Form): 140 140 """ -
django/contrib/auth/views.py
105 105 def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', 106 106 email_template_name='registration/password_reset_email.html', 107 107 password_reset_form=PasswordResetForm, token_generator=default_token_generator, 108 post_reset_redirect=None ):108 post_reset_redirect=None, from_email=None): 109 109 if post_reset_redirect is None: 110 110 post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done') 111 111 if request.method == "POST": … … 114 114 opts = {} 115 115 opts['use_https'] = request.is_secure() 116 116 opts['token_generator'] = token_generator 117 opts['from_email'] = from_email 117 118 if is_admin_site: 118 119 opts['domain_override'] = request.META['HTTP_HOST'] 119 120 else: -
django/contrib/auth/tests/urls.py
14 14 (r'^logout/custom_query/$', 'django.contrib.auth.views.logout', dict(redirect_field_name='follow')), 15 15 (r'^logout/next_page/$', 'django.contrib.auth.views.logout', dict(next_page='/somewhere/')), 16 16 (r'^remote_user/$', remote_user_auth_view), 17 (r'^password_reset_from_email/$', 'django.contrib.auth.views.password_reset', dict(from_email='staffmember@example.com')), 17 18 ) 18 19 -
django/contrib/auth/tests/views.py
52 52 self.assertEquals(response.status_code, 302) 53 53 self.assertEquals(len(mail.outbox), 1) 54 54 self.assert_("http://" in mail.outbox[0].body) 55 self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) 55 56 57 def test_email_found_custom_from(self): 58 "Email is sent if a valid email address is provided for password reset when a custom from_email is provided." 59 response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'}) 60 self.assertEquals(response.status_code, 302) 61 self.assertEquals(len(mail.outbox), 1) 62 self.assertEquals("staffmember@example.com", mail.outbox[0].from_email) 63 56 64 def _test_confirm_start(self): 57 65 # Start by creating the email 58 66 response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})