Skip to content

Commit

Permalink
Fixed ValueError to AuthCanceled and AuthFailed
Browse files Browse the repository at this point in the history
SocialAuthExceptionMiddleware doesn't handle ValueError - only SocialAuthBaseException
  • Loading branch information
syabro committed Mar 3, 2013
1 parent adc462d commit 91d8b68
Showing 1 changed file with 3 additions and 3 deletions.
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 91d8b68

Please sign in to comment.