summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-08-27 19:14:54 +0200
committerRuben Pollan <meskio@sindominio.net>2016-08-27 19:16:47 +0200
commitec86a9c330fd6c183563ca3b2c5b6b2068bb0e3b (patch)
tree9e5a227994c0715055d34201a3f552a6cc79be82
parentb97643c5b8cbee752659269f0be15ff460efe193 (diff)
[bug] don't cache failed sessions
We were caching sessions even when the authentication has failed, making impossible to try again with a different password. - Resolves: #8226
-rw-r--r--bonafide/src/leap/bonafide/_protocol.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bonafide/src/leap/bonafide/_protocol.py b/bonafide/src/leap/bonafide/_protocol.py
index e50d020..726185e 100644
--- a/bonafide/src/leap/bonafide/_protocol.py
+++ b/bonafide/src/leap/bonafide/_protocol.py
@@ -70,6 +70,11 @@ class BonafideProtocol(object):
self._sessions[full_id] = session
return session
+ def _del_session_errback(self, failure, full_id):
+ if full_id in self._sessions:
+ del self._sessions[full_id]
+ return failure
+
# Service public methods
def do_signup(self, full_id, password):
@@ -94,6 +99,7 @@ class BonafideProtocol(object):
session = self._get_session(provider, full_id, password)
d = session.signup(username, password)
d.addCallback(return_user, session)
+ d.addErrback(self._del_session_errback, full_id)
return d
def do_authenticate(self, full_id, password):
@@ -125,6 +131,7 @@ class BonafideProtocol(object):
session = self._get_session(provider, full_id, password)
d = session.authenticate()
d.addCallback(return_token_and_uuid, session)
+ d.addErrback(self._del_session_errback, full_id)
return d
def do_logout(self, full_id):