[patch] problems with multiple window logins, last_login not updated
|Reported by:||oggie rob <oz.robharvey@…>||Owned by:||adrian|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I was making some changes to multiple windows of the admin interface, was prompted for a login as my session had expired, and promptly lost everything in my model! I was greeted with a nasty looking page complaining that none of the required fields were filled in, which indeed was true. In the process of debugging I discovered the last_login field was not being updated in admin. They are in the same method so this patch fixes both.
To reproduce the login failure:
- Add the missing change_stage staff_member_required thing (it's in magic_removal, but is needed to reproduce this problem): see 
- turn on the admin interface on some model(s)
- set your myproj/settings.py SESSION_COOKIE_AGE to something very low so you can set plenty of session expirations. I used 30 (meaning, 30 seconds). Log out and log in again to get the low cookie expiration.
- display a change list
- wait until the session expires
- use "open in new window" or "open in new tab" to have the edit view of several objects open in different windows. In other words, right-click on the href for those items in the change list. Each window will produce a login prompt.
- Try to log in on each of those edit views
The first screen should be fine, subsequent ones will return you to the edit screen with no fields displayed/selected and lots of errors. (You can use the back button to recover your work, however.) Minor variations on the above steps will lead to similar problems.
The problem is the POST has been encoded, and when it is used again of course the view function can't find the things it is looking for.