summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/soledad/soledadbootstrapper.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-03-18 15:12:54 -0300
committerTomás Touceda <chiiph@leap.se>2014-03-18 15:12:54 -0300
commit0dda039a576e376acea49bb5aec2a0aab8cd2354 (patch)
tree5fdb4cfa0a175d15d99a4995af01ddeef8190e1e /src/leap/bitmask/services/soledad/soledadbootstrapper.py
parent03b74407d4051e2c5dfb62b8e6e8899008030d26 (diff)
parent21e8d1a4539b0b0837ca0763de4974ac6f216bf7 (diff)
Merge remote-tracking branch 'refs/remotes/drebs/feature/5191_handle-invalid-auth-token-error' into develop
Diffstat (limited to 'src/leap/bitmask/services/soledad/soledadbootstrapper.py')
-rw-r--r--src/leap/bitmask/services/soledad/soledadbootstrapper.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index 7aa86a02..ad5ee4d0 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -44,6 +44,7 @@ from leap.common.check import leap_assert, leap_assert_type, leap_check
from leap.common.files import which
from leap.keymanager import KeyManager, openpgp
from leap.keymanager.errors import KeyNotFound
+from leap.soledad.common.errors import InvalidAuthTokenError
from leap.soledad.client import Soledad, BootstrapSequenceError
logger = logging.getLogger(__name__)
@@ -139,6 +140,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
gen_key = QtCore.Signal(dict)
local_only_ready = QtCore.Signal(dict)
soledad_timeout = QtCore.Signal()
+ soledad_invalid_auth_token = QtCore.Signal()
soledad_failed = QtCore.Signal()
def __init__(self):
@@ -258,6 +260,12 @@ class SoledadBootstrapper(AbstractBootstrapper):
return server_url, cert_file
+ def _soledad_sync_errback(self, failure):
+ failure.trap(InvalidAuthTokenError)
+ # in the case of an invalid token we have already turned off mail and
+ # warned the user in _do_soledad_sync()
+
+
def load_and_sync_soledad(self, uuid=None, offline=False):
"""
Once everthing is in the right place, we instantiate and sync
@@ -298,7 +306,8 @@ class SoledadBootstrapper(AbstractBootstrapper):
self._keymanager.get_key(
address, openpgp.OpenPGPKey,
private=True, fetch_remote=False)
- threads.deferToThread(self._do_soledad_sync)
+ d = threads.deferToThread(self._do_soledad_sync)
+ d.addErrback(self._soledad_sync_errback)
except KeyNotFound:
logger.debug("Key not found. Generating key for %s" %
(address,))
@@ -350,6 +359,9 @@ class SoledadBootstrapper(AbstractBootstrapper):
# ubuntu folks.
sync_tries -= 1
continue
+ except InvalidAuthTokenError:
+ self.soledad_invalid_auth_token.emit()
+ raise
except Exception as e:
logger.exception("Unhandled error while syncing "
"soledad: %r" % (e,))
@@ -444,6 +456,10 @@ class SoledadBootstrapper(AbstractBootstrapper):
except (sqlite_ProgrammingError, sqlcipher_ProgrammingError) as e:
logger.exception("%r" % (e,))
raise
+ except InvalidAuthTokenError:
+ # token is invalid, probably expired
+ logger.error('Invalid auth token while trying to sync Soledad')
+ raise
except Exception as exc:
logger.exception("Unhandled error while syncing "
"soledad: %r" % (exc,))