From ec86a9c330fd6c183563ca3b2c5b6b2068bb0e3b Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Sat, 27 Aug 2016 19:14:54 +0200 Subject: [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 --- bonafide/src/leap/bonafide/_protocol.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bonafide') 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): -- cgit v1.2.3