Opened 19 years ago
Last modified 19 years ago
#4015 closed
login and logout should update request.user — at Version 1
| Reported by: | James Bennett | Owned by: | Adrian Holovaty |
|---|---|---|---|
| Component: | Contrib apps | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Currently, django.contrib.auth.login and django.contrib.auth.logout don't update request.user, which means that things which happen after those functions are called (e.g., templates which include {% if user.is_authenticated %}) will not see that the authentication status has changed.
This causes some counterintuitive behavior:
- If you use
django.contrib.auth.views.logoutand have it return a template directly, the template may "think" you're still logged in even though you aren't (becauserequest.useris still aUserobject). Having it return a redirect instead shows the expected behavior, because it ends up generating a new request). - If you use forms which subclass
django.contrib.auth.forms.AuthenticationForm(e.g., the form for posting registered comments), the form may still think you're anonymous even after it's successfully logged you in (becauserequest.useris still anAnonymousUserobject). This is why, for example, entering a username and password when previewing a registered comment seems to do nothing (the form will still think those fields are required, because it doesn't know you've successfully logged in during that request).
Having login and logout update request.user would clear this up.
Change History (1)
comment:1 by , 19 years ago
| Description: | modified (diff) |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.