summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0078
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2011-08-18 00:35:37 -0700
committerNathan Fritz <fritzy@netflint.net>2011-08-18 00:35:37 -0700
commit4ea22ff69bac4b619b1eeb918c67a209f6e953ee (patch)
treecc4a245ea03429d59b192cb3f79b3bee95343ba8 /sleekxmpp/plugins/xep_0078
parent3853898ab36fa1a74b5d9d5ea3070c3e8e1bc0f2 (diff)
parent7d8aa4157bc7a602243996a45268b172629a6ae3 (diff)
downloadslixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.gz
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.bz2
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.xz
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.zip
Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop
Diffstat (limited to 'sleekxmpp/plugins/xep_0078')
-rw-r--r--sleekxmpp/plugins/xep_0078/legacyauth.py39
1 files changed, 25 insertions, 14 deletions
diff --git a/sleekxmpp/plugins/xep_0078/legacyauth.py b/sleekxmpp/plugins/xep_0078/legacyauth.py
index bdd2df67..edb8f314 100644
--- a/sleekxmpp/plugins/xep_0078/legacyauth.py
+++ b/sleekxmpp/plugins/xep_0078/legacyauth.py
@@ -56,11 +56,17 @@ class xep_0078(base_plugin):
iq['type'] = 'get'
iq['to'] = self.xmpp.boundjid.host
iq['auth']['username'] = self.xmpp.boundjid.user
- resp = iq.send(now=True)
- if resp is None or resp['type'] != 'result':
+ try:
+ resp = iq.send(now=True)
+ except IqError:
log.info("Authentication failed: %s" % resp['error']['condition'])
- self.xmpp.event('failed_auth', resp, direct=True)
+ self.xmpp.event('failed_auth', direct=True)
+ self.xmpp.disconnect()
+ return True
+ except IqTimeout:
+ log.info("Authentication failed: %s" % 'timeout')
+ self.xmpp.event('failed_auth', direct=True)
self.xmpp.disconnect()
return True
@@ -91,18 +97,23 @@ class xep_0078(base_plugin):
iq['auth']['password'] = self.xmpp.password
# Step 3: Send credentials
- result = iq.send(now=True)
- if result is not None and result.attrib['type'] == 'result':
- self.xmpp.features.add('auth')
-
- self.xmpp.authenticated = True
- log.debug("Established Session")
- self.xmpp.sessionstarted = True
- self.xmpp.session_started_event.set()
- self.xmpp.event('session_start')
- else:
+ try:
+ result = iq.send(now=True)
+ except IqError as err:
log.info("Authentication failed")
self.xmpp.disconnect()
- self.xmpp.event("failed_auth")
+ self.xmpp.event("failed_auth", direct=True)
+ except IqTimeout:
+ log.info("Authentication failed")
+ self.xmpp.disconnect()
+ self.xmpp.event("failed_auth", direct=True)
+
+ self.xmpp.features.add('auth')
+
+ self.xmpp.authenticated = True
+ log.debug("Established Session")
+ self.xmpp.sessionstarted = True
+ self.xmpp.session_started_event.set()
+ self.xmpp.event('session_start')
return True