From 70aad432c81766c9bdae9932f80c5745527a0f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 25 Apr 2024 08:19:37 +0200 Subject: [PATCH] pipeline: make sure uid is string It is stored as string in the database, so make conversion early. Fixes https://github.com/python-social-auth/social-app-django/issues/568 --- social_core/pipeline/social_auth.py | 2 +- social_core/tests/backends/test_bitbucket_datacenter.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/social_core/pipeline/social_auth.py b/social_core/pipeline/social_auth.py index 1fd124aff..1c5940e75 100644 --- a/social_core/pipeline/social_auth.py +++ b/social_core/pipeline/social_auth.py @@ -6,7 +6,7 @@ def social_details(backend, details, response, *args, **kwargs): def social_uid(backend, details, response, *args, **kwargs): - return {"uid": backend.get_user_id(details, response)} + return {"uid": str(backend.get_user_id(details, response))} def auth_allowed(backend, details, response, *args, **kwargs): diff --git a/social_core/tests/backends/test_bitbucket_datacenter.py b/social_core/tests/backends/test_bitbucket_datacenter.py index 8a3d3f9c5..dda5fbb6f 100644 --- a/social_core/tests/backends/test_bitbucket_datacenter.py +++ b/social_core/tests/backends/test_bitbucket_datacenter.py @@ -83,7 +83,7 @@ def test_login(self): self.assertEqual(len(user.social), 1) social = user.social[0] - self.assertEqual(social.uid, 1) + self.assertEqual(social.uid, "1") self.assertEqual(social.extra_data["first_name"], "Erlich") self.assertEqual(social.extra_data["last_name"], "Bachman") self.assertEqual(social.extra_data["email"], "erlich@bachmanity.com") @@ -109,7 +109,7 @@ def test_login(self): def test_refresh_token(self): _, social = self.do_refresh_token() - self.assertEqual(social.uid, 1) + self.assertEqual(social.uid, "1") self.assertEqual(social.extra_data["first_name"], "Erlich") self.assertEqual(social.extra_data["last_name"], "Bachman") self.assertEqual(social.extra_data["email"], "erlich@bachmanity.com")