[Python-modules-commits] [python-social-auth] 08/61: fix clef backend by access ID in correct way

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:14:01 UTC 2016


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to tag v0.2.13
in repository python-social-auth.

commit ca8f61f9f993bd221dce853a84f534f02304ab2f
Author: Jesse Pollak <jpollak92 at gmail.com>
Date:   Tue Jul 14 16:44:48 2015 -0700

    fix clef backend by access ID in correct way
---
 social/backends/clef.py            | 14 ++++++++++++--
 social/tests/backends/test_clef.py |  6 +++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/social/backends/clef.py b/social/backends/clef.py
index 7a034db..c1beff5 100644
--- a/social/backends/clef.py
+++ b/social/backends/clef.py
@@ -23,6 +23,9 @@ class ClefOAuth2(BaseOAuth2):
         params['redirect_url'] = params.pop('redirect_uri')
         return params
 
+    def get_user_id(self, response, details):
+        return details.get('info').get('id')
+
     def get_user_details(self, response):
         """Return user details from Github account"""
         info = response.get('info')
@@ -30,9 +33,16 @@ class ClefOAuth2(BaseOAuth2):
             first_name=info.get('first_name'),
             last_name=info.get('last_name')
         )
+
+        email = info.get('email', '')
+        if email:
+            username = email.split('@', 1)[0]
+        else:
+            username = info.get('id')
+
         return {
-            'username': response.get('clef_id'),
-            'email': info.get('email', ''),
+            'username': username,
+            'email': email,
             'fullname': fullname,
             'first_name': first_name,
             'last_name': last_name,
diff --git a/social/tests/backends/test_clef.py b/social/tests/backends/test_clef.py
index d70f9a2..2a3ae15 100644
--- a/social/tests/backends/test_clef.py
+++ b/social/tests/backends/test_clef.py
@@ -6,17 +6,17 @@ from social.tests.backends.oauth import OAuth2Test
 class ClefOAuth2Test(OAuth2Test):
     backend_path = 'social.backends.clef.ClefOAuth2'
     user_data_url = 'https://clef.io/api/v1/info'
-    expected_username = '123456789'
+    expected_username = 'test'
     access_token_body = json.dumps({
         'access_token': 'foobar'
     })
     user_data_body = json.dumps({
         'info': {
+            'id': '123456789',
             'first_name': 'Test',
             'last_name': 'User',
             'email': 'test at example.com'
-        },
-        'clef_id': '123456789'
+        }
     })
 
     def test_login(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git



More information about the Python-modules-commits mailing list