246 | | # TODO: set last_login with an event. |
247 | | user.last_login = datetime.datetime.now() |
248 | | user.save() |
249 | | if request.POST.has_key('post_data'): |
250 | | post_data = _decode_post_data(request.POST['post_data']) |
251 | | if post_data and not post_data.has_key(LOGIN_FORM_KEY): |
252 | | # overwrite request.POST with the saved post_data, and continue |
253 | | request.POST = post_data |
254 | | request.user = user |
255 | | return None |
256 | | else: |
257 | | request.session.delete_test_cookie() |
258 | | return http.HttpResponseRedirect(request.path) |
259 | | else: |
260 | | return self.display_login_form(request, ERROR_MESSAGE) |
| 246 | |
| 247 | if self.has_permission(request): |
| 248 | # TODO: set last_login with an event. |
| 249 | user.last_login = datetime.datetime.now() |
| 250 | user.save() |
| 251 | if request.POST.has_key('post_data'): |
| 252 | post_data = _decode_post_data(request.POST['post_data']) |
| 253 | if post_data and not post_data.has_key(LOGIN_FORM_KEY): |
| 254 | # overwrite request.POST with the saved post_data, and continue |
| 255 | request.POST = post_data |
| 256 | request.user = user |
| 257 | return None |
| 258 | else: |
| 259 | request.session.delete_test_cookie() |
| 260 | return http.HttpResponseRedirect(request.path) |
| 261 | |
| 262 | # logged in a user without permission to access this admin site, un-do that |
| 263 | # and fall through to re-display the login form with an error message. |
| 264 | logout(request) |
| 265 | |
| 266 | return self.display_login_form(request, ERROR_MESSAGE) |