Skip to content

Commit

Permalink
Merge branch 'master' of github.com:omab/django-social-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Mar 4, 2013
2 parents c4c2094 + 671b3c7 commit d9d16af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions social_auth/backends/contrib/evernote.py
Expand Up @@ -53,6 +53,15 @@ class EvernoteBackend(OAuthBackend):
('edam_expires', 'expires')
]

@classmethod
def extra_data(cls, user, uid, response, details=None):
data = super(EvernoteBackend, cls).extra_data(user, uid, response, details)
# Evernote returns expiration timestamp in miliseconds, so it needs to
# be normalized.
if 'expires' in data:
data['expires'] = unicode(int(data['expires']) / 1000)
return data

def get_user_details(self, response):
"""Return user details from Evernote account"""
return {
Expand Down
6 changes: 3 additions & 3 deletions social_auth/backends/contrib/vkontakte.py
Expand Up @@ -16,7 +16,7 @@

from social_auth.backends import SocialAuthBackend, OAuthBackend, BaseAuth, \
BaseOAuth2
from social_auth.exceptions import AuthTokenRevoked, AuthException
from social_auth.exceptions import AuthTokenRevoked, AuthException, AuthCanceled, AuthFailed
from social_auth.utils import setting, log, dsa_urlopen


Expand Down Expand Up @@ -88,7 +88,7 @@ def auth_complete(self, *args, **kwargs):

if not 'id' in self.request.GET or \
not app_cookie in self.request.COOKIES:
raise ValueError('VKontakte authentication is not completed')
raise AuthCanceled(self)

cookie_dict = dict(item.split('=') for item in
self.request.COOKIES[app_cookie].split('&'))
Expand All @@ -98,7 +98,7 @@ def auth_complete(self, *args, **kwargs):
hash = md5(check_str + setting('VKONTAKTE_APP_SECRET')).hexdigest()

if hash != cookie_dict['sig'] or int(cookie_dict['expire']) < time():
raise ValueError('VKontakte authentication failed: invalid hash')
raise AuthFailed('VKontakte authentication failed: invalid hash')
else:
kwargs.update({
'auth': self,
Expand Down

0 comments on commit d9d16af

Please sign in to comment.