#10460 closed (fixed)
Better redirect for logout view of Authentication
| Reported by: | Felipe 'chronos' Prenholato | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.auth | Version: | dev |
| Severity: | Keywords: | Authentication, login, logout, redirect, kkmp2 | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
This patch make logout view use same style of login view to redirect user to any page, but maintain compatibility with current mode.
With this patch you can use some url like:
/logout/?next=/page-x/
With single code in urls.py:
(r'^logout/$', 'django.contrib.auth.views.logout'),
Attachments (3)
Change History (12)
by , 17 years ago
| Attachment: | views.py.diff added |
|---|
comment:1 by , 17 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 17 years ago
| milestone: | → 1.1 |
|---|---|
| Triage Stage: | Design decision needed → Accepted |
comment:3 by , 17 years ago
| Needs tests: | unset |
|---|
comment:4 by , 17 years ago
I've attempted to write some tests for the first patch. My patch includes the changes from the views.py.diff patch.
The tests do not cover the case where the next_page option is specified in the urlconf. The reason is that django.contrib.auth.urls is used, this urlconf does not a contain such an entry. The tests uses django.contrib.auth.SESSION_KEY in client.request.session to check if a user is logged in.
If someone could confirm that the patch is going in the right direction, I'll make an attempt to write documentation as well.
by , 17 years ago
| Attachment: | fixed-auth-logout-with-redirect.diff added |
|---|
logout redirects like login view, with tests
comment:5 by , 17 years ago
| Needs tests: | set |
|---|
I have fixed a wrong variable name in path. I fixed it here a bit after send path but miss to send updated views.py.diff file.
I include in this last changes of steingrd but not tested with test classes because don't know how, so, someone need to do it.
by , 17 years ago
| Attachment: | auth-logout-with-redirect.diff added |
|---|
logout view redirects like login view, with tests
comment:6 by , 17 years ago
| Needs tests: | unset |
|---|
Since my initial tests did not catch the bug pointed out by Chronos, I made a second attempt. This time I added a urlconf for the tests. In addition to an regressiontest for the case where the initial patch used the wrong variable name, I've added a test for the next_page keyword argument.
comment:7 by , 17 years ago
| Keywords: | kkmp2 added |
|---|
comment:8 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Patch to make logout redirects like login view.