♻️(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:
committed by
aleb_the_flash
parent
11cd85d4eb
commit
5db4b09106
@@ -75,26 +75,12 @@ class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
|
|||||||
user = User.objects.get(sub=sub)
|
user = User.objects.get(sub=sub)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
if self.get_settings("OIDC_CREATE_USER", True):
|
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:
|
else:
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
return user
|
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user