summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0078
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-17 21:30:47 -0700
committerLance Stout <lancestout@gmail.com>2011-08-17 21:30:47 -0700
commit004eabf80959ebcaeddf2e15065bd4f50ad10974 (patch)
treee62c243c6b1a539a0fa71030011eb88762068b6b /sleekxmpp/plugins/xep_0078
parent62230fc970f86b11bc74ee448e30cbe93f477e72 (diff)
downloadslixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.gz
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.bz2
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.xz
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.zip
Update plugins that use Iq stanzas to work with new exceptions.
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