Django

Code

Ticket #903 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

change login_required

Reported by: Dagur Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The way it is now the login_required decorator only redirects to /accounts/login

I want to be able to change this so I don't have to change my mod_python settings just to make /accounts urls handled by Django.

Attachments

Change History

11/26/05 01:20:08 changed by adrian

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

(In [1440]) Fixed #903 -- Added login_url argument to user_passes_test view decorator. Didn't add it to login_required decorator because that would turn login_required into a callable decorator, which would break backwards compatibility.

11/26/05 01:21:34 changed by adrian

I added a login_url argument to the user_passes_test view decorator. See the new docs at http://www.djangoproject.com/documentation/authentication/#limiting-access-to-logged-in-users-that-pass-a-test .

11/26/05 05:20:53 changed by Dagur

why is backwards compatibility an issue? :-/

06/15/06 10:41:22 changed by umbrae@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.

This doesn't actually fix the problem with login_required.

As a previous user suggested somewhere else, perhaps a different approach that would save backwards compatibility would be to allow LOGIN_URL to be settable in settings.py.

For now, the best workaround would be to create your own decorator:

 from django.contrib.auth.decorators import user_passes_test
 login_needed = user_passes_test(lambda u: not u.is_anonymous(), login_url='/login/')

A fix should still be looked into however - it works as a workaround, but shouldn't be a hard and fast solution.

08/12/06 00:24:58 changed by adrian

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

If the current behavior is an issue, see the comment by umbrae@gmail.com for a workaround.


Add/Change #903 (change login_required)




Change Properties
Action