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
7e2bcf36
Commit
7e2bcf36
authored
May 12, 2011
by
Michael Hall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for STRICT_USERNAMES before defaulting the nickname to openiduser
parent
ab11f190
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
django_openid_auth/auth.py
+9
-3
No files found.
django_openid_auth/auth.py
View file @
7e2bcf36
...
@@ -142,7 +142,15 @@ class OpenIDBackend:
...
@@ -142,7 +142,15 @@ 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
nickname
=
nickname
or
'openiduser'
nickname
=
nickname
or
'openiduser'
# See if we already have this nickname assigned to a username
# See if we already have this nickname assigned to a username
try
:
try
:
user
=
User
.
objects
.
get
(
username__exact
=
nickname
)
user
=
User
.
objects
.
get
(
username__exact
=
nickname
)
...
@@ -173,11 +181,9 @@ class OpenIDBackend:
...
@@ -173,11 +181,9 @@ class OpenIDBackend:
if
getattr
(
settings
,
'OPENID_STRICT_USERNAMES'
,
False
):
if
getattr
(
settings
,
'OPENID_STRICT_USERNAMES'
,
False
):
if
details
[
'nickname'
]
is
None
or
details
[
'nickname'
]
==
''
:
raise
StrictUsernameViolation
(
"No username"
)
if
User
.
objects
.
filter
(
username__exact
=
nickname
)
.
count
()
>
0
:
if
User
.
objects
.
filter
(
username__exact
=
nickname
)
.
count
()
>
0
:
raise
StrictUsernameViolation
(
"Duplicate username:
%
s"
%
nickname
)
raise
StrictUsernameViolation
(
"Duplicate username:
%
s"
%
nickname
)
# Pick a username for the user based on their nickname,
# Pick a username for the user based on their nickname,
# checking for conflicts.
# checking for conflicts.
i
=
1
i
=
1
...
...
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