Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-cas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-cas
Commits
58229f4d
Commit
58229f4d
authored
Sep 05, 2008
by
Brodie Rao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added @login_required replacement
parent
d0e24f70
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
+15
-1
django_cas/decorators.py
+15
-1
No files found.
django_cas/decorators.py
View file @
58229f4d
...
...
@@ -4,7 +4,7 @@ from django.contrib.auth import REDIRECT_FIELD_NAME
from
django.contrib.auth.decorators
import
_CheckLogin
from
django.http
import
HttpResponseForbidden
__all__
=
[
'permission_required'
,
'user_passes_test'
]
__all__
=
[
'
login_required'
,
'
permission_required'
,
'user_passes_test'
]
class
CheckLoginOrForbid
(
_CheckLogin
):
...
...
@@ -27,6 +27,20 @@ def user_passes_test(test_func, login_url=None,
return
decorate
def
login_required
(
function
=
None
,
redirect_field_name
=
REDIRECT_FIELD_NAME
):
"""Replacement for django.contrib.auth.decorators.login_required that
returns 403 Forbidden if the user is already logged in.
"""
actual_decorator
=
user_passes_test
(
lambda
u
:
u
.
is_authenticated
(),
redirect_field_name
=
redirect_field_name
)
if
function
:
return
actual_decorator
(
function
)
return
actual_decorator
def
permission_required
(
perm
,
login_url
=
None
):
"""Replacement for django.contrib.auth.decorators.permission_required that
returns 403 Forbidden if the user is already logged in.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment