Opened 14 years ago

Closed 12 years ago

Last modified 12 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 13 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 by Carl Meyer, 14 years ago

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 by Luke Plant, 14 years ago

Type: New feature

comment:3 by Luke Plant, 14 years ago

Severity: Normal

by Ulrich Petri, 13 years ago

Attachment: t15552.patch added

comment:4 by Ulrich Petri, 13 years ago

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 by Ulrich Petri, 13 years ago

Keywords: dceu2011 added

comment:6 by Russell Keith-Magee, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Jannis Leidel, 13 years ago

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 by Jannis Leidel, 13 years ago

Triage Stage: Ready for checkinAccepted

comment:9 by Ulrich Petri, 13 years ago

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 by Jannis Leidel, 13 years ago

Yeah, that's fine.

comment:11 by floguy, 12 years ago

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 by Carl Meyer <carl@…>, 12 years ago

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 by Tim Graham <timograham@…>, 12 years ago

comment:14 by Danilo Bargen, 12 years ago

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 by Danilo Bargen, 12 years ago

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