From 5db4b09106a79d17a45d549313bfd3c48bb7efbd Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 4 Nov 2024 10:15:29 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(backend)=20remove=20redundan?= =?UTF-8?q?t=20create=5Fuser=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove redundant wrapper method that duplicates SUB validation logic. Already validated in parent class, following the pattern established by @sampaccoud in People and Impress modules. --- src/backend/core/authentication/backends.py | 24 +++++---------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/backend/core/authentication/backends.py b/src/backend/core/authentication/backends.py index 41774d2c..ddfa60ad 100644 --- a/src/backend/core/authentication/backends.py +++ b/src/backend/core/authentication/backends.py @@ -75,26 +75,12 @@ class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend): user = User.objects.get(sub=sub) except User.DoesNotExist: if self.get_settings("OIDC_CREATE_USER", True): - user = self.create_user(user_info) + user = User.objects.create( + sub=sub, + email=user_info.get("email"), + password="!", # noqa: S106 + ) else: user = None return user - - def create_user(self, claims): - """Return a newly created User instance.""" - - sub = claims.get("sub") - - if sub is None: - raise SuspiciousOperation( - _("Claims contained no recognizable user identification") - ) - - user = User.objects.create( - sub=sub, - email=claims.get("email"), - password="!", # noqa: S106 - ) - - return user