Przeglądaj źródła

[desktop] Handle oauth2 library import errors

Erick Tryzelaar 10 lat temu
rodzic
commit
0386ff3698

+ 3 - 1
desktop/core/src/desktop/auth/views.py

@@ -19,7 +19,7 @@
 try:
   import oauth2 as oauth
 except:
-  pass
+  oauth = None
 
 import cgi
 import datetime
@@ -178,6 +178,8 @@ def _profile_dict(user):
 
 @login_notrequired
 def oauth_login(request):
+  assert oauth is not None
+
   consumer = oauth.Consumer(OAUTH.CONSUMER_KEY.get(), OAUTH.CONSUMER_SECRET.get())
   client = oauth.Client(consumer)
   resp, content = client.request(OAUTH.REQUEST_TOKEN_URL.get(), "POST", body=urllib.urlencode({

+ 3 - 1
desktop/libs/liboauth/src/liboauth/backend.py

@@ -41,7 +41,7 @@ import liboauth.conf
 try:
   import oauth2 as oauth
 except:
-  pass
+  oauth = None
 
 
 LOG = logging.getLogger(__name__)
@@ -91,6 +91,7 @@ class OAuthBackend(DesktopBackendBase):
 
   @classmethod
   def handleAuthenticationRequest(self, request):
+    assert oauth is not None
  
     if 'oauth_verifier' in request.GET:
         social = 'twitter'
@@ -188,6 +189,7 @@ class OAuthBackend(DesktopBackendBase):
 
   @classmethod
   def handleLoginRequest(self, request):
+    assert oauth is not None
     
     redirect_uri = 'http://' + request.get_host() + '/oauth/social_login/oauth_authenticated'
     response_type = "code"

+ 1 - 1
desktop/libs/liboauth/src/liboauth/views.py

@@ -18,7 +18,7 @@
 try:
   import oauth2 as oauth
 except:
-  pass
+  oauth = None
  
 import logging
 import urllib