diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 5b306e4..6f19080 100644
a
|
b
|
from django.views.decorators.cache import never_cache
|
22 | 22 | @never_cache |
23 | 23 | def login(request, template_name='registration/login.html', |
24 | 24 | redirect_field_name=REDIRECT_FIELD_NAME, |
25 | | authentication_form=AuthenticationForm): |
| 25 | authentication_form=AuthenticationForm, |
| 26 | extra_context=None): |
26 | 27 | """Displays the login form and handles the login action.""" |
27 | 28 | |
28 | 29 | redirect_to = request.REQUEST.get(redirect_field_name, '') |
… |
… |
def login(request, template_name='registration/login.html',
|
61 | 62 | redirect_field_name: redirect_to, |
62 | 63 | 'site': current_site, |
63 | 64 | 'site_name': current_site.name, |
64 | | }, context_instance=RequestContext(request)) |
| 65 | }, context_instance=RequestContext(request, extra_context)) |
65 | 66 | |
66 | | def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME): |
| 67 | def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME, extra_context=None): |
67 | 68 | "Logs out the user and displays 'You are logged out' message." |
68 | 69 | from django.contrib.auth import logout |
69 | 70 | logout(request) |
… |
… |
def logout(request, next_page=None, template_name='registration/logged_out.html'
|
77 | 78 | 'site': current_site, |
78 | 79 | 'site_name': current_site.name, |
79 | 80 | 'title': _('Logged out') |
80 | | }, context_instance=RequestContext(request)) |
| 81 | }, context_instance=RequestContext(request, extra_context)) |
81 | 82 | else: |
82 | 83 | # Redirect to this page until the session has been cleared. |
83 | 84 | return HttpResponseRedirect(next_page or request.path) |
84 | 85 | |
85 | | def logout_then_login(request, login_url=None): |
| 86 | def logout_then_login(request, login_url=None, extra_context=None): |
86 | 87 | "Logs out the user if he is logged in. Then redirects to the log-in page." |
87 | 88 | if not login_url: |
88 | 89 | login_url = settings.LOGIN_URL |
89 | | return logout(request, login_url) |
| 90 | return logout(request, login_url, extra_context=extra_context) |
90 | 91 | |
91 | 92 | def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): |
92 | 93 | "Redirects the user to the login page, passing the given 'next' page" |
… |
… |
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_N
|
105 | 106 | def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', |
106 | 107 | email_template_name='registration/password_reset_email.html', |
107 | 108 | password_reset_form=PasswordResetForm, token_generator=default_token_generator, |
108 | | post_reset_redirect=None, from_email=None): |
| 109 | post_reset_redirect=None, from_email=None, extra_context=None): |
109 | 110 | if post_reset_redirect is None: |
110 | 111 | post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done') |
111 | 112 | if request.method == "POST": |
… |
… |
def password_reset(request, is_admin_site=False, template_name='registration/pas
|
125 | 126 | form = password_reset_form() |
126 | 127 | return render_to_response(template_name, { |
127 | 128 | 'form': form, |
128 | | }, context_instance=RequestContext(request)) |
| 129 | }, context_instance=RequestContext(request, extra_context)) |
129 | 130 | |
130 | | def password_reset_done(request, template_name='registration/password_reset_done.html'): |
131 | | return render_to_response(template_name, context_instance=RequestContext(request)) |
| 131 | def password_reset_done(request, template_name='registration/password_reset_done.html', extra_context=None): |
| 132 | return render_to_response(template_name, context_instance=RequestContext(request, extra_context)) |
132 | 133 | |
133 | 134 | # Doesn't need csrf_protect since no-one can guess the URL |
134 | 135 | def password_reset_confirm(request, uidb36=None, token=None, template_name='registration/password_reset_confirm.html', |
135 | 136 | token_generator=default_token_generator, set_password_form=SetPasswordForm, |
136 | | post_reset_redirect=None): |
| 137 | post_reset_redirect=None, extra_context=None): |
137 | 138 | """ |
138 | 139 | View that checks the hash in a password reset link and presents a |
139 | 140 | form for entering a new password. |
… |
… |
def password_reset_confirm(request, uidb36=None, token=None, template_name='regi
|
162 | 163 | context_instance['validlink'] = False |
163 | 164 | form = None |
164 | 165 | context_instance['form'] = form |
165 | | return render_to_response(template_name, context_instance=context_instance) |
| 166 | return render_to_response(template_name, context_instance=context_instance, extra_context=extra_context) |
166 | 167 | |
167 | | def password_reset_complete(request, template_name='registration/password_reset_complete.html'): |
168 | | return render_to_response(template_name, context_instance=RequestContext(request, |
169 | | {'login_url': settings.LOGIN_URL})) |
| 168 | def password_reset_complete(request, template_name='registration/password_reset_complete.html', extra_context=None): |
| 169 | context = {'login_url': settings.LOGIN_URL} |
| 170 | if extra_context: context.update(extra_context) |
| 171 | return render_to_response(template_name, context_instance=RequestContext(request, context)) |
170 | 172 | |
171 | 173 | @csrf_protect |
172 | 174 | @login_required |
173 | 175 | def password_change(request, template_name='registration/password_change_form.html', |
174 | | post_change_redirect=None, password_change_form=PasswordChangeForm): |
| 176 | post_change_redirect=None, password_change_form=PasswordChangeForm, extra_context=None): |
175 | 177 | if post_change_redirect is None: |
176 | 178 | post_change_redirect = reverse('django.contrib.auth.views.password_change_done') |
177 | 179 | if request.method == "POST": |
… |
… |
def password_change(request, template_name='registration/password_change_form.ht
|
183 | 185 | form = password_change_form(user=request.user) |
184 | 186 | return render_to_response(template_name, { |
185 | 187 | 'form': form, |
186 | | }, context_instance=RequestContext(request)) |
| 188 | }, context_instance=RequestContext(request, extra_context)) |
187 | 189 | |
188 | | def password_change_done(request, template_name='registration/password_change_done.html'): |
189 | | return render_to_response(template_name, context_instance=RequestContext(request)) |
| 190 | def password_change_done(request, template_name='registration/password_change_done.html', extra_context=None): |
| 191 | return render_to_response(template_name, context_instance=RequestContext(request, extra_context)) |