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
a729f686
Commit
a729f686
authored
Aug 30, 2013
by
Jason Bau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial, dead simple way to allow superuser to log in as anyone
Conflicts: lms/envs/common.py lms/urls.py
parent
b753641d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
common/djangoapps/student/views.py
+13
-0
lms/envs/common.py
+3
-0
lms/urls.py
+4
-0
No files found.
common/djangoapps/student/views.py
View file @
a729f686
...
...
@@ -77,6 +77,19 @@ def csrf_token(context):
' name="csrfmiddlewaretoken" value="
%
s" /></div>'
%
(
csrf_token
))
def
superuser_login_as
(
request
,
username
):
if
not
request
.
user
.
is_superuser
:
return
HttpResponse
(
'Permission denied'
)
try
:
u1
=
User
.
objects
.
get
(
username
=
username
)
u1
.
backend
=
'django.contrib.auth.backends.ModelBackend'
except
User
.
DoesNotExist
:
return
HttpResponse
(
'User not found'
)
logout
(
request
)
login
(
request
,
u1
)
return
HttpResponse
(
'You are now logged in as '
+
username
)
# NOTE: This view is not linked to directly--it is called from
# branding/views.py:index(), which is cached for anonymous users.
# This means that it should always return the same thing for anon
...
...
lms/envs/common.py
View file @
a729f686
...
...
@@ -179,6 +179,9 @@ MITX_FEATURES = {
# Sends the user's deanonymized email address to xqueue with code responses
# DO NOT SET if you don't want the anonymous user id to be linked with user.email in xqueue (Stanford does)
'SEND_USERS_EMAILADDR_WITH_CODERESPONSE'
:
False
,
# OP Superusers can log in as anyone
'ENABLE_SUPERUSER_LOGIN_AS'
:
False
,
}
# Used for A/B testing
...
...
lms/urls.py
View file @
a729f686
...
...
@@ -420,6 +420,10 @@ urlpatterns += (
url
(
r'^shoppingcart/'
,
include
(
'shoppingcart.urls'
)),
)
if
settings
.
MITX_FEATURES
.
get
(
'ENABLE_SUPERUSER_LOGIN_AS'
):
urlpatterns
+=
(
url
(
r'^su_login_as/(?P<username>[\w.@+-]+)/?$'
,
'student.views.superuser_login_as'
,
name
=
'impersonate'
),
)
if
settings
.
MITX_FEATURES
.
get
(
'AUTH_USE_OPENID_PROVIDER'
):
urlpatterns
+=
(
...
...
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