summaryrefslogtreecommitdiff
path: root/service/pixelated/config
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-09-26 12:54:45 +0200
committerNavaL <ayoyo@thoughtworks.com>2016-09-26 12:54:45 +0200
commit4462f7f8ca4b0e22396ef3a82cee884f8d348276 (patch)
treecaf5db25a885207c4aa823d04c2e9d0f9cbcce72 /service/pixelated/config
parent833ed49c24a2b1ba87d5bdf7c1d660e68602defc (diff)
rearranged leap session creation to not sync nor setup account/fetcher, when using the cache
Issue #773
Diffstat (limited to 'service/pixelated/config')
-rw-r--r--service/pixelated/config/leap.py11
-rw-r--r--service/pixelated/config/sessions.py10
2 files changed, 8 insertions, 13 deletions
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py
index 54518bae..3d307fc7 100644
--- a/service/pixelated/config/leap.py
+++ b/service/pixelated/config/leap.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
import logging
from collections import namedtuple
+from twisted.cred.error import UnauthorizedLogin
from twisted.internet import defer, threads
from leap.common.events import (server as events_server)
from leap.soledad.common.errors import InvalidAuthTokenError
@@ -45,16 +46,6 @@ def initialize_leap_multi_user(provider_hostname,
@defer.inlineCallbacks
def create_leap_session(provider, username, password, auth=None):
leap_session = yield LeapSessionFactory(provider).create(username, password, auth)
- try:
- yield leap_session.first_required_sync()
- except InvalidAuthTokenError:
- try:
- leap_session.close()
- except Exception, e:
- log.error(e)
- leap_session = LeapSessionFactory(provider).create(username, password, auth)
- yield leap_session.first_required_sync()
-
defer.returnValue(leap_session)
diff --git a/service/pixelated/config/sessions.py b/service/pixelated/config/sessions.py
index 9ce0a212..3a8ffc56 100644
--- a/service/pixelated/config/sessions.py
+++ b/service/pixelated/config/sessions.py
@@ -2,8 +2,12 @@ from __future__ import absolute_import
import os
import errno
+import traceback
+
import requests
import logging
+
+import sys
from twisted.internet import defer, threads, reactor
from leap.soledad.common.crypto import WrongMacError, UnknownMacMethodError
from leap.soledad.client import Soledad
@@ -34,6 +38,7 @@ class LeapSessionFactory(object):
session = SessionCache.lookup_session(key)
if not session:
session = yield self._create_new_session(username, password, auth)
+ yield session.first_required_sync()
SessionCache.remember_session(key, session)
defer.returnValue(session)
@@ -178,8 +183,8 @@ class LeapSession(object):
self.stop_background_jobs()
unregister(events.KEYMANAGER_FINISHED_KEY_GENERATION, uid=self.account_email())
self.soledad.close()
- self.remove_from_cache()
self._close_account()
+ self.remove_from_cache()
@property
def is_closed(self):
@@ -224,8 +229,7 @@ class SessionCache(object):
if session is not None and session.is_closed:
SessionCache.remove_session(key)
return None
- else:
- return session
+ return session
@staticmethod
def remember_session(key, session):