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
3f810add
Commit
3f810add
authored
Jun 14, 2013
by
Jason Bau
Committed by
Joe Blaylock
Jun 18, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle the case where an existing user has email returned by shib
By linking the users
parent
d779fae5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
common/djangoapps/external_auth/views.py
+31
-0
No files found.
common/djangoapps/external_auth/views.py
View file @
3f810add
...
@@ -147,9 +147,40 @@ def external_login_or_signup(request,
...
@@ -147,9 +147,40 @@ def external_login_or_signup(request,
internal_user
=
eamap
.
user
internal_user
=
eamap
.
user
if
internal_user
is
None
:
if
internal_user
is
None
:
if
settings
.
MITX_FEATURES
.
get
(
'AUTH_USE_SHIB'
):
# if we are using shib, try to link accounts using email
try
:
link_user
=
User
.
objects
.
get
(
email
=
eamap
.
external_email
)
if
not
ExternalAuthMap
.
objects
.
filter
(
user
=
link_user
)
.
exists
():
# if there's no pre-existing linked eamap, we link the user
eamap
.
user
=
link_user
eamap
.
save
()
internal_user
=
link_user
log
.
debug
(
'Linking existing account for
%
s'
%
eamap
.
external_email
)
# now pass through to log in
else
:
# otherwise, set external_email to '' to ask for a new one at user signup
eamap
.
external_email
=
''
eamap
.
save
()
log
.
debug
(
'User with external login found for
%
s, asking for new email during signup'
%
email
)
return
signup
(
request
,
eamap
)
except
User
.
DoesNotExist
:
log
.
debug
(
'No user for
%
s yet, doing signup'
%
eamap
.
external_email
)
return
signup
(
request
,
eamap
)
else
:
log
.
debug
(
'No user for
%
s yet, doing signup'
%
eamap
.
external_email
)
log
.
debug
(
'No user for
%
s yet, doing signup'
%
eamap
.
external_email
)
return
signup
(
request
,
eamap
)
return
signup
(
request
,
eamap
)
# We trust shib's authentication, so no need to authenticate using the password again
if
settings
.
MITX_FEATURES
.
get
(
'AUTH_USE_SHIB'
):
user
=
internal_user
# Assuming this 'AUTHENTICATION_BACKENDS' is set in settings, which I think is safe
if
settings
.
AUTHENTICATION_BACKENDS
:
auth_backend
=
settings
.
AUTHENTICATION_BACKENDS
[
0
]
else
:
auth_backend
=
'django.contrib.auth.backends.ModelBackend'
user
.
backend
=
auth_backend
else
:
uname
=
internal_user
.
username
uname
=
internal_user
.
username
user
=
authenticate
(
username
=
uname
,
password
=
eamap
.
internal_password
)
user
=
authenticate
(
username
=
uname
,
password
=
eamap
.
internal_password
)
if
user
is
None
:
if
user
is
None
:
...
...
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