Django

Code

Ticket #3372 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

django.contrib.auth.views.password_change is tied to the URL /accounts/login/

Reported by: Rob Hudson <treborhudson@gmail.com> Assigned to: adrian
Milestone: Component: Contrib apps
Version: SVN Keywords: login
Cc: treborhudson@gmail.com, john@calixto.net Triage Stage: Design decision needed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

There's a problem when trying to set up your login/auth URLs different than Django's defaults. The one I've been unable to work around without copying/pasting all of the function is django.contrib.auth.views.password_change.

Here's the gist of the problem...

  1. password_change is decorated with Django's default login_required decorator.
  2. The default login_required decorator uses the (un-overridable) LOGIN_URL variable.
  3. The LOGIN_URL variable is set to "/accounts/login/".

I see 2 fixes...

1) Move LOGIN_URL to global_settings.py

This would allow the default Django login_required decorator to be easily overridden, making things much easier across the board. (Anything decorated with login_required is fixed, the shortcut methods like "redirect_to_login" and "logout_then_login" are fixed.

And there's already variables for the contrib.comments system in global_settings.py so there's already precedent for having contrib apps with stuff in global_settings.py. :)

2) Provide an un-decorated password_change method

Having a password_change method that isn't decorated allows me to decorate it with my own login_required decorator, which redirects to my own login URL if not authenticated.

Either of these should be possible without breaking backwards compatibility.

I have a patch for either. Should I submit both patches? Or should I wait for a design decision and submit the patch for what's decided (if either of the above)?

Attachments

Change History

01/26/07 12:58:43 changed by Rob Hudson <treborhudson@gmail.com>

  • cc set to treborhudson@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

(Adding myself to CC list and un-checking "Has Patch")

01/30/07 02:54:20 changed by Simon G. <dev@simon.net.nz>

  • keywords set to login.
  • stage changed from Unreviewed to Design decision needed.

02/16/07 13:32:20 changed by thebanana <john@calixto.net>

  • cc changed from treborhudson@gmail.com to treborhudson@gmail.com, john@calixto.net.
  • has_patch deleted.

You can already change LOGIN_URL. Just put this in your project's settings.py file:

import django.contrib.auth

django.contrib.auth.LOGIN_URL = '/mynew/loginurl/'

08/25/07 00:11:18 changed by SmileyChris

  • status changed from new to closed.
  • resolution set to fixed.

LOGIN_URL was put into global_settings a while back

08/25/07 00:11:46 changed by SmileyChris

  • status changed from new to closed.
  • resolution set to fixed.

LOGIN_URL was put into global_settings in [5072]


Add/Change #3372 (django.contrib.auth.views.password_change is tied to the URL /accounts/login/)




Change Properties
Action