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
7900c768
Commit
7900c768
authored
Jul 19, 2011
by
Michael Nelson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REFACTOR: Merged the blank nickname check into the required attrs code.
parent
030e869d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
django_openid_auth/auth.py
+4
-7
django_openid_auth/tests/test_views.py
+4
-0
No files found.
django_openid_auth/auth.py
View file @
7900c768
...
@@ -147,12 +147,6 @@ class OpenIDBackend:
...
@@ -147,12 +147,6 @@ class OpenIDBackend:
first_name
=
first_name
,
last_name
=
last_name
)
first_name
=
first_name
,
last_name
=
last_name
)
def
_get_available_username
(
self
,
nickname
,
identity_url
):
def
_get_available_username
(
self
,
nickname
,
identity_url
):
# If we're being strict about usernames, throw an error if we didn't
# get one back from the provider
if
getattr
(
settings
,
'OPENID_STRICT_USERNAMES'
,
False
):
if
nickname
is
None
or
nickname
==
''
:
raise
StrictUsernameViolation
(
"No username"
)
# If we don't have a nickname, and we're not being strict, use a default
# If we don't have a nickname, and we're not being strict, use a default
nickname
=
nickname
or
'openiduser'
nickname
=
nickname
or
'openiduser'
...
@@ -206,8 +200,11 @@ class OpenIDBackend:
...
@@ -206,8 +200,11 @@ class OpenIDBackend:
def
create_user_from_openid
(
self
,
openid_response
):
def
create_user_from_openid
(
self
,
openid_response
):
details
=
self
.
_extract_user_details
(
openid_response
)
details
=
self
.
_extract_user_details
(
openid_response
)
required_attrs
=
getattr
(
settings
,
'OPENID_SREG_REQUIRED_FIELDS'
,
[])
required_attrs
=
getattr
(
settings
,
'OPENID_SREG_REQUIRED_FIELDS'
,
[])
if
getattr
(
settings
,
'OPENID_STRICT_USERNAMES'
,
False
):
required_attrs
.
append
(
'nickname'
)
for
required_attr
in
required_attrs
:
for
required_attr
in
required_attrs
:
if
required_attr
not
in
details
:
if
required_attr
not
in
details
or
not
details
[
required_attr
]
:
raise
RequiredAttributeNotReturned
(
raise
RequiredAttributeNotReturned
(
"The required attribute '{0}' was not returned."
.
format
(
"The required attribute '{0}' was not returned."
.
format
(
required_attr
))
required_attr
))
...
...
django_openid_auth/tests/test_views.py
View file @
7900c768
...
@@ -137,6 +137,8 @@ class RelyingPartyTests(TestCase):
...
@@ -137,6 +137,8 @@ class RelyingPartyTests(TestCase):
self
.
old_teams_map
=
getattr
(
settings
,
'OPENID_LAUNCHPAD_TEAMS_MAPPING'
,
{})
self
.
old_teams_map
=
getattr
(
settings
,
'OPENID_LAUNCHPAD_TEAMS_MAPPING'
,
{})
self
.
old_use_as_admin_login
=
getattr
(
settings
,
'OPENID_USE_AS_ADMIN_LOGIN'
,
False
)
self
.
old_use_as_admin_login
=
getattr
(
settings
,
'OPENID_USE_AS_ADMIN_LOGIN'
,
False
)
self
.
old_follow_renames
=
getattr
(
settings
,
'OPENID_FOLLOW_RENAMES'
,
False
)
self
.
old_follow_renames
=
getattr
(
settings
,
'OPENID_FOLLOW_RENAMES'
,
False
)
self
.
old_required_fields
=
getattr
(
settings
,
'OPENID_SREG_REQUIRED_FIELDS'
,
[])
settings
.
OPENID_CREATE_USERS
=
False
settings
.
OPENID_CREATE_USERS
=
False
settings
.
OPENID_STRICT_USERNAMES
=
False
settings
.
OPENID_STRICT_USERNAMES
=
False
...
@@ -145,6 +147,7 @@ class RelyingPartyTests(TestCase):
...
@@ -145,6 +147,7 @@ class RelyingPartyTests(TestCase):
settings
.
OPENID_LAUNCHPAD_TEAMS_MAPPING
=
{}
settings
.
OPENID_LAUNCHPAD_TEAMS_MAPPING
=
{}
settings
.
OPENID_USE_AS_ADMIN_LOGIN
=
False
settings
.
OPENID_USE_AS_ADMIN_LOGIN
=
False
settings
.
OPENID_FOLLOW_RENAMES
=
False
settings
.
OPENID_FOLLOW_RENAMES
=
False
settings
.
OPENID_SREG_REQUIRED_FIELDS
=
[]
def
tearDown
(
self
):
def
tearDown
(
self
):
settings
.
LOGIN_REDIRECT_URL
=
self
.
old_login_redirect_url
settings
.
LOGIN_REDIRECT_URL
=
self
.
old_login_redirect_url
...
@@ -155,6 +158,7 @@ class RelyingPartyTests(TestCase):
...
@@ -155,6 +158,7 @@ class RelyingPartyTests(TestCase):
settings
.
OPENID_LAUNCHPAD_TEAMS_MAPPING
=
self
.
old_teams_map
settings
.
OPENID_LAUNCHPAD_TEAMS_MAPPING
=
self
.
old_teams_map
settings
.
OPENID_USE_AS_ADMIN_LOGIN
=
self
.
old_use_as_admin_login
settings
.
OPENID_USE_AS_ADMIN_LOGIN
=
self
.
old_use_as_admin_login
settings
.
OPENID_FOLLOW_RENAMES
=
self
.
old_follow_renames
settings
.
OPENID_FOLLOW_RENAMES
=
self
.
old_follow_renames
settings
.
OPENID_SREG_REQUIRED_FIELDS
=
self
.
old_required_fields
setDefaultFetcher
(
None
)
setDefaultFetcher
(
None
)
super
(
RelyingPartyTests
,
self
)
.
tearDown
()
super
(
RelyingPartyTests
,
self
)
.
tearDown
()
...
...
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