diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-07-04 18:25:48 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-07-05 16:12:15 -0300 |
commit | decb04c3bf4b07815e901de64e04b1c1c6754e03 (patch) | |
tree | 2f2938c3596bd7221045e430afd2c87be3932714 /src | |
parent | e494017766bf59f18556ce59af933d357165d3bd (diff) |
Refactor methods and emit event when we know uid is not None
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/crypto/srpauth.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/leap/crypto/srpauth.py b/src/leap/crypto/srpauth.py index 781d67ae..8f5fb3d3 100644 --- a/src/leap/crypto/srpauth.py +++ b/src/leap/crypto/srpauth.py @@ -268,27 +268,29 @@ class SRPAuth(QtCore.QObject): raise SRPAuthenticationError(self.tr("Unknown error (%s)") % (auth_result.status_code,)) - json_content = json.loads(content) + return json.loads(content) + def _extract_data(self, json_content): try: M2 = json_content.get("M2", None) uid = json_content.get("id", None) token = json_content.get("token", None) except Exception as e: logger.error(e) - raise Exception("Something went wrong with the login") - - events_signal(proto.CLIENT_UID, content=uid) + raise SRPAuthenticationError("Something went wrong with the " + "login") self.set_uid(uid) self.set_token(token) if M2 is None or self.get_uid() is None: logger.error("Something went wrong. Content = %r" % - (content,)) + (json_content,)) raise SRPAuthenticationError(self.tr("Problem getting data " "from server")) + events_signal(proto.CLIENT_UID, content=uid) + return M2 def _verify_session(self, M2): @@ -359,6 +361,10 @@ class SRPAuth(QtCore.QObject): partial(self._threader, self._process_challenge), username=username) + d.addCallback( + partial(self._threader, + self._extract_data), + username=username) d.addCallback(partial(self._threader, self._verify_session)) |