Opened 6 years ago

Closed 4 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: master
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: UI/UX:

Description

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 Mnewman 6 years ago.
Patch with desired (assumed) functionality and updated docs

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by Mnewman

Patch with desired (assumed) functionality and updated docs

comment:1 Changed 6 years ago by Mnewman

  • Component changed from Uncategorized to Authentication
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Allow login_required to specify a custom login_url to Allow login_required to specify login_url like user_passes_test
  • Triage Stage changed from Unreviewed to Design decision needed
  • Version changed from 1.1 to SVN

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 5 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 4 years ago by mlavin

  • Resolution set to fixed
  • Status changed from new to closed

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

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