Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#10460 closed (fixed)

Better redirect for logout view of Authentication

Reported by: chronos Owned by: nobody
Component: contrib.auth Version: master
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: UI/UX:

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 chronos 6 years ago.
Patch to make logout redirects like login view.
fixed-auth-logout-with-redirect.diff (3.6 KB) - added by chronos 6 years ago.
logout redirects like login view, with tests
auth-logout-with-redirect.diff (5.5 KB) - added by steingrd 6 years ago.
logout view redirects like login view, with tests

Download all attachments as: .zip

Change History (12)

Changed 6 years ago by chronos

Patch to make logout redirects like login view.

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Design decision needed to Accepted

comment:3 Changed 6 years ago by Alex

  • Needs tests unset

comment:4 Changed 6 years ago by steingrd

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.

Changed 6 years ago by chronos

logout redirects like login view, with tests

comment:5 Changed 6 years ago by chronos

  • 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.

Changed 6 years ago by steingrd

logout view redirects like login view, with tests

comment:6 Changed 6 years ago by steingrd

  • 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 Changed 6 years ago by kkubasik

  • Keywords kkmp2 added

comment:8 Changed 6 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:9 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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