Opened 15 years ago
Closed 15 years ago
#13714 closed (fixed)
Login Required decorator should support LOGIN_URL
| Reported by: | Owned by: | mhlakhani | |
|---|---|---|---|
| Component: | contrib.auth | Version: | |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
In django.contrib.auth.decorators, both the user_passes_test and permission_required decorators allow the caller to specify a custom LOGIN_URL to redirect visitors to. However, the login_required decorator does not allow the caller to specify a custom login URL. This feature would be helpful in my opinion and not hard to add.
Attachments (1)
Change History (10)
comment:1 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 15 years ago
| Has patch: | set |
|---|
comment:3 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 15 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | set |
I agree that this is easy to implement and see not reason why this could not be implemented on trunk.
Currently however you can already do this under the implementation of providing login_required with "function=your_own_decorator" under which you can implement your own version of the lambda statement.
I would however be +0 for implementing this as it is a nicety but there are ways to do this without modification to the django source.
comment:5 by , 15 years ago
| Patch needs improvement: | set |
|---|---|
| Version: | 1.2 |
You'd also want to make the new argument the last, as some people will be using positional arguments to call the decorator.
But yeah, it seems useful enough to add (and no backwards compatibility issues after the argument is moved to the end).
comment:8 by , 15 years ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
I've updated the patch to include docs and tests for this. It's all isolated in a branch here: http://github.com/ericflo/django/compare/ticket13714
I added the patch. This should work.