From 3bc2b1bd3ed0a74c5ab344890c86fcf0b766f999 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 9 Nov 2024 17:02:57 +0000 Subject: [PATCH] use preferred_username and fallback to name --- pandora/app/oidc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora/app/oidc.py b/pandora/app/oidc.py index 31a5adcd..be397374 100644 --- a/pandora/app/oidc.py +++ b/pandora/app/oidc.py @@ -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