♻️(backend) remove redundant create_user method

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.
This commit is contained in:
lebaudantoine
2024-11-04 10:15:29 +01:00
committed by aleb_the_flash
parent 11cd85d4eb
commit 5db4b09106

View File

@@ -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