(backend) add test to secure updating user when matched on email

We had doubts that the user was correctly updated in the case where
its identity was matched on the email and not on the sub. I added
a test and confirmed that it was working correctly. I still modified
the backend to update the user based on its "id" instead of its "sub"
because it was confusing, but both actually work the same.
This commit is contained in:
Samuel Paccoud - DINUM
2025-01-03 17:37:41 +01:00
committed by Samuel Paccoud
parent 9f83ea7111
commit 945f55f50d
2 changed files with 46 additions and 3 deletions

View File

@@ -134,4 +134,4 @@ class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
)
if has_changed:
updated_claims = {key: value for key, value in claims.items() if value}
self.UserModel.objects.filter(sub=user.sub).update(**updated_claims)
self.UserModel.objects.filter(id=user.id).update(**updated_claims)