Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#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)

views.py.diff (1.2 KB ) - added by Felipe 'chronos' Prenholato 16 years ago.
Patch to make logout redirects like login view.
fixed-auth-logout-with-redirect.diff (3.6 KB ) - added by Felipe 'chronos' Prenholato 16 years ago.
logout redirects like login view, with tests
auth-logout-with-redirect.diff (5.5 KB ) - added by steingrd 16 years ago.
logout view redirects like login view, with tests

Download all attachments as: .zip

Change History (12)

by Felipe 'chronos' Prenholato, 16 years ago

Attachment: views.py.diff added

Patch to make logout redirects like login view.

comment:1 by Chris Beaven, 16 years ago

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedDesign decision needed

comment:2 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: Design decision neededAccepted

comment:3 by Alex Gaynor, 16 years ago

Needs tests: unset

comment:4 by steingrd, 16 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 Felipe 'chronos' Prenholato, 16 years ago

logout redirects like login view, with tests

comment:5 by Felipe 'chronos' Prenholato, 16 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 steingrd, 16 years ago

logout view redirects like login view, with tests

comment:6 by steingrd, 16 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 Kevin Kubasik, 16 years ago

Keywords: kkmp2 added

comment:8 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [10332]) Fixed #10460: the logout view can now redirect like the rest of the auth views. Thanks, chronos and steingrd.

comment:9 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top