diff options
author | Lance Stout <lancestout@gmail.com> | 2012-10-24 12:56:54 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-10-24 12:56:54 -0700 |
commit | a22ca228cc3a121da8bad4268c39bff5190db969 (patch) | |
tree | d9d4c28fe772a906acb5bf9692f78cae2e485dab /sleekxmpp/plugins | |
parent | d0666a5eb6acf7dfe100c1b501f8ad688eb5f70e (diff) | |
download | slixmpp-a22ca228cc3a121da8bad4268c39bff5190db969.tar.gz slixmpp-a22ca228cc3a121da8bad4268c39bff5190db969.tar.bz2 slixmpp-a22ca228cc3a121da8bad4268c39bff5190db969.tar.xz slixmpp-a22ca228cc3a121da8bad4268c39bff5190db969.zip |
Lock the bound JID in the JID cache.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r-- | sleekxmpp/plugins/xep_0078/legacyauth.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/xep_0078/legacyauth.py b/sleekxmpp/plugins/xep_0078/legacyauth.py index be9fe3c5..7e2d7bdf 100644 --- a/sleekxmpp/plugins/xep_0078/legacyauth.py +++ b/sleekxmpp/plugins/xep_0078/legacyauth.py @@ -11,6 +11,7 @@ import hashlib import random import sys +from sleekxmpp.jid import JID from sleekxmpp.exceptions import IqError, IqTimeout from sleekxmpp.stanza import Iq, StreamFeatures from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin @@ -95,10 +96,11 @@ class XEP_0078(BasePlugin): iq['auth']['username'] = self.xmpp.requested_jid.user # A resource is required, so create a random one if necessary - if self.xmpp.requested_jid.resource: - iq['auth']['resource'] = self.xmpp.requested_jid.resource - else: - iq['auth']['resource'] = '%s' % random.random() + resource = self.xmpp.requested_jid.resource + if not resource: + resource = uuid.uuid4() + + iq['auth']['resource'] = resource if 'digest' in resp['auth']['fields']: log.debug('Authenticating via jabber:iq:auth Digest') @@ -130,6 +132,12 @@ class XEP_0078(BasePlugin): self.xmpp.features.add('auth') self.xmpp.authenticated = True + + self.xmpp.boundjid = JID(self.xmpp.requested_jid, + resource=resource, + cache_lock=True) + self.xmpp.event('session_bind', self.xmpp.boundjid, direct=True) + log.debug("Established Session") self.xmpp.sessionstarted = True self.xmpp.session_started_event.set() |