use preferred_username and fallback to name
This commit is contained in:
parent
5c6c7e37c7
commit
3bc2b1bd3e
1 changed files with 5 additions and 1 deletions
|
@ -12,7 +12,11 @@ User = get_user_model()
|
|||
class OIDCAuthenticationBackend(mozilla_django_oidc.auth.OIDCAuthenticationBackend):
|
||||
def create_user(self, claims):
|
||||
user = super(OIDCAuthenticationBackend, self).create_user(claims)
|
||||
username = claims.get("preferred_username")
|
||||
username = None
|
||||
for key in ('preferred_username', 'name'):
|
||||
if claims.get(key):
|
||||
username = claims[key]
|
||||
break
|
||||
n = 1
|
||||
if username and username != user.username:
|
||||
uname = username
|
||||
|
|
Loading…
Reference in a new issue