Opened 6 years ago

Closed 4 years ago

Last modified 3 years ago

#15552 closed New feature (fixed)

LOGIN_URL should allow named urls

Reported by: Wolph Owned by: nobody
Component: contrib.auth Version: 1.2
Severity: Normal Keywords: login_url logout_url login_redirect_url named_url url_tag dceu2011
Cc: gezuru@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

To adhere to the DRY principle it seems quite silly that one has to hardcode the LOGIN_URL, LOGOUT_URL and LOGIN_REDIRECT_URL.

It would be logical to simply use a named url so it always redirects to the login view you specified, regardless of the SCRIPT_NAME and your url configs.

Attachments (1)

t15552.patch (11.7 KB) - added by Ulrich Petri 5 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 6 years ago by Carl Meyer

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

I think this is a valid point, and the proposed solution is the right one. See also discussion at http://groups.google.com/group/django-developers/browse_frm/thread/fa3661888716f940/8b4d0cf8f34e5493

Also refs #8906.

comment:2 Changed 5 years ago by Luke Plant

Type: New feature

comment:3 Changed 5 years ago by Luke Plant

Severity: Normal

Changed 5 years ago by Ulrich Petri

Attachment: t15552.patch added

comment:4 Changed 5 years ago by Ulrich Petri

Easy pickings: unset
Has patch: set
UI/UX: unset

I've added a patch that implements Alex Gaynor's suggestion from the thread mentioned above and basically applies the logic from redirect() to LOGIN_URL and LOGIN_REDIRECT_URL

comment:5 Changed 5 years ago by Ulrich Petri

Keywords: dceu2011 added

comment:6 Changed 5 years ago by Russell Keith-Magee

Triage Stage: AcceptedReady for checkin

comment:7 Changed 5 years ago by Jannis Leidel

Patch needs improvement: set

The resolve_url function fits better in the django.shortcuts module instead of a new django.utils.urls module.

comment:8 Changed 5 years ago by Jannis Leidel

Triage Stage: Ready for checkinAccepted

comment:9 Changed 5 years ago by Ulrich Petri

I placed it in utils because I wasn't sure you'd want resolve_url as part of the "public" shortcuts module.
But if that is ok I'll update the patch.

comment:10 Changed 5 years ago by Jannis Leidel

Yeah, that's fine.

comment:11 Changed 4 years ago by floguy

Patch needs improvement: unset

I've updated this patch for 1.5 trunk as of today and have submitted a pull request on GitHub https://github.com/django/django/pull/343

comment:12 Changed 4 years ago by Carl Meyer <carl@…>

Resolution: fixed
Status: newclosed

In [a78dd109e6c81c49e90e36e9b793bad67c46c23c]:

Fixed #15552 -- LOGIN_URL and LOGIN_REDIRECT_URL can take URLpattern names.

Thanks UloPe and Eric Florenzano for the patch, and Malcolm Tredinnick for
review.

comment:13 Changed 4 years ago by Tim Graham <timograham@…>

comment:14 Changed 3 years ago by Danilo Bargen

The current implementation does not allow named url arguments, right?

I'm using django-social-auth and would like to point LOGIN_URL to resolve('socialauth_begin', args=('google-oauth2',)).

comment:15 Changed 3 years ago by Danilo Bargen

Cc: gezuru@… added
Note: See TracTickets for help on using tickets.
Back to Top