Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-openid-auth
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-openid-auth
Commits
e33d9822
Commit
e33d9822
authored
Oct 13, 2010
by
Michael Hall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds OPENID_FOLLOW_RENAMES to change django username if they change in the OpenID provider
parent
7069378a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
django_openid_auth/auth.py
+3
-0
django_openid_auth/tests/test_views.py
+12
-2
No files found.
django_openid_auth/auth.py
View file @
e33d9822
...
@@ -191,6 +191,9 @@ class OpenIDBackend:
...
@@ -191,6 +191,9 @@ class OpenIDBackend:
if
details
[
'email'
]:
if
details
[
'email'
]:
user
.
email
=
details
[
'email'
]
user
.
email
=
details
[
'email'
]
updated
=
True
updated
=
True
if
getattr
(
settings
,
'OPENID_FOLLOW_RENAMES'
,
False
):
user
.
username
=
details
[
'nickname'
]
updated
=
True
if
updated
:
if
updated
:
user
.
save
()
user
.
save
()
...
...
django_openid_auth/tests/test_views.py
View file @
e33d9822
...
@@ -285,6 +285,10 @@ class RelyingPartyTests(TestCase):
...
@@ -285,6 +285,10 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
def
test_login_update_details_rename
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
return
self
.
test_login_update_details
()
def
test_login_update_details
(
self
):
def
test_login_update_details
(
self
):
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
...
@@ -312,13 +316,19 @@ class RelyingPartyTests(TestCase):
...
@@ -312,13 +316,19 @@ class RelyingPartyTests(TestCase):
response
=
self
.
complete
(
openid_response
)
response
=
self
.
complete
(
openid_response
)
self
.
assertRedirects
(
response
,
'http://testserver/getuser/'
)
self
.
assertRedirects
(
response
,
'http://testserver/getuser/'
)
# And they are now logged in as testuser (the passed in
# If OPENID_FOLLOW_RENAMES, they are logged in as
# someuser (the passed in nickname has changed the username)
#
# Otherwise they are now logged in as testuser (the passed in
# nickname has not caused the username to change).
# nickname has not caused the username to change).
response
=
self
.
client
.
get
(
'/getuser/'
)
response
=
self
.
client
.
get
(
'/getuser/'
)
if
getattr
(
settings
,
'OPENID_FOLLOW_RENAMES'
,
False
):
self
.
assertEquals
(
response
.
content
,
'someuser'
)
else
:
self
.
assertEquals
(
response
.
content
,
'testuser'
)
self
.
assertEquals
(
response
.
content
,
'testuser'
)
# The user's full name and email have been updated.
# The user's full name and email have been updated.
user
=
User
.
objects
.
get
(
username
=
'testuser'
)
user
=
User
.
objects
.
get
(
username
=
response
.
content
)
self
.
assertEquals
(
user
.
first_name
,
'Some'
)
self
.
assertEquals
(
user
.
first_name
,
'Some'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
...
...
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