From: Matías Aguirre Date: Wed, 9 May 2012 06:08:51 +0000 (-0300) Subject: Protect email access for those users that don't disclose yhaoo email. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=671c6e02f7b6806fb0293b1597aaecede8f218d7;p=django-social-auth.git Protect email access for those users that don't disclose yhaoo email. --- diff --git a/social_auth/backends/contrib/yahoo.py b/social_auth/backends/contrib/yahoo.py index 9ac234b..2e1b3f2 100644 --- a/social_auth/backends/contrib/yahoo.py +++ b/social_auth/backends/contrib/yahoo.py @@ -49,8 +49,12 @@ class YahooOAuthBackend(OAuthBackend): """Return user details from Yahoo Profile""" fname = response.get('givenName') lname = response.get('familyName') + if 'emails' in response: + email = response.get('emails')[0]['handle'] + else: + email = '' return {USERNAME: response.get('nickname'), - 'email': response.get('emails')[0]['handle'], + 'email': email, 'fullname': '%s %s' % (fname, lname), 'first_name': fname, 'last_name': lname}