Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
19e79a0d
Commit
19e79a0d
authored
Jun 23, 2014
by
Jason Bau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
middleware for CMS logging out all sneakpeek users
parent
198f23ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
cms/djangoapps/sneakpeek/__init__.py
+0
-0
cms/djangoapps/sneakpeek/middleware.py
+26
-0
cms/envs/common.py
+3
-0
No files found.
cms/djangoapps/sneakpeek/__init__.py
0 → 100644
View file @
19e79a0d
cms/djangoapps/sneakpeek/middleware.py
0 → 100644
View file @
19e79a0d
"""
Middleware class handling sneakpeek in cms, which should never be allowed
"""
from
student.models
import
UserProfile
from
django.contrib.auth
import
logout
from
django.shortcuts
import
redirect
class
SneakPeekLogoutMiddleware
(
object
):
"""
Middleware that logs out all sneakpeek users and then retries (redirects) the same URL
"""
def
process_request
(
self
,
request
):
"""
logs out all sneakpeek users and then retries (redirects) the same URL
"""
#Do nothing with AnonymousUser
if
request
.
user
.
is_anonymous
():
return
None
#Do nothing with non-sneakpeek user
if
UserProfile
.
has_registered
(
request
.
user
):
return
None
logout
(
request
)
return
redirect
(
request
.
get_full_path
())
cms/envs/common.py
View file @
19e79a0d
...
@@ -229,6 +229,9 @@ MIDDLEWARE_CLASSES = (
...
@@ -229,6 +229,9 @@ MIDDLEWARE_CLASSES = (
# use Django built in clickjacking protection
# use Django built in clickjacking protection
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
# Log out sneakpeek users
'sneakpeek.middleware.SneakPeekLogoutMiddleware'
,
)
)
# Clickjacking protection can be enabled by setting this to 'DENY'
# Clickjacking protection can be enabled by setting this to 'DENY'
...
...
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