Opened 13 years ago

Closed 12 years ago

#11770 closed (fixed)

Allow login_required to specify login_url like user_passes_test

Reported by: anonymous Owned by: nobody
Component: contrib.auth Version: dev
Severity: Keywords: login auth
Cc: tomovo@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


All up to login_required Django allows one to specify a custom login_url when the user is not actually logged in.

However, login_required omits this parameter when calling user_passes_test and thus forces me to rewrite that piece of code to do that. I think it would be a simple and probably backwards-compatible change to add an optional parameter to override the login_url even in login_required.

Attachments (1)

11770-login-decorator.diff (4.0 KB) - added by Michael Newman 13 years ago.
Patch with desired (assumed) functionality and updated docs

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by Michael Newman

Attachment: 11770-login-decorator.diff added

Patch with desired (assumed) functionality and updated docs

comment:1 Changed 13 years ago by Michael Newman

Component: UncategorizedAuthentication
Has patch: set
Summary: Allow login_required to specify a custom login_urlAllow login_required to specify login_url like user_passes_test
Triage Stage: UnreviewedDesign decision needed
Version: 1.1SVN

This is interesting and pretty trivial IMO. Marking DDN and putting a patch up that I think accomplishes this right and changes the docs. Also adds the other part of the docs for user_passes_test and changes absolute URL to absolute path, both of which should probably be their own tickets.

comment:2 Changed 13 years ago by django@…

Hi, is there a problem to apply this patch on current working version? It is quite old and trivial. I just need such behaviour of login_required decorator but it is always better to have it from trunk than apply this patch to every update.

comment:3 Changed 12 years ago by Mark Lavin

Resolution: fixed
Status: newclosed

This is a duplicate of #13714 which is now fixed in [13723].

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