Mercurial > libervia-backend
comparison src/core/xmpp.py @ 2172:545a1261ac3b
core, plugin XEP-0077: in-band registration fix and move:
in-band was partially in core for historical reason, it has been moved to XEP-0077, and fixed. It is still incomplete, but should work for basic accounts creation.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Mar 2017 20:59:31 +0100 |
parents | 1d3f73e065e1 |
children | f51315500eb1 |
comparison
equal
deleted
inserted
replaced
2171:978011533892 | 2172:545a1261ac3b |
---|---|
1088 return | 1088 return |
1089 log.debug(u"iqFallback: xml = [%s]" % (iq.toXml())) | 1089 log.debug(u"iqFallback: xml = [%s]" % (iq.toXml())) |
1090 generic.FallbackHandler.iqFallback(self, iq) | 1090 generic.FallbackHandler.iqFallback(self, iq) |
1091 | 1091 |
1092 | 1092 |
1093 class RegisteringAuthenticator(xmlstream.ConnectAuthenticator): | |
1094 | |
1095 def __init__(self, host, jabber_host, user_login, user_pass, email, deferred, profile): | |
1096 xmlstream.ConnectAuthenticator.__init__(self, jabber_host) | |
1097 self.host = host | |
1098 self.jabber_host = jabber_host | |
1099 self.user_login = user_login | |
1100 self.user_pass = user_pass | |
1101 self.user_email = email | |
1102 self.deferred = deferred | |
1103 self.profile = profile | |
1104 log.debug(_(u"Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host}) | |
1105 | |
1106 def connectionMade(self): | |
1107 log.debug(_(u"Connection made with %s" % self.jabber_host)) | |
1108 self.xmlstream.namespace = C.NS_CLIENT | |
1109 self.xmlstream.sendHeader() | |
1110 | |
1111 iq = xmlstream.IQ(self.xmlstream, 'set') | |
1112 iq["to"] = self.jabber_host | |
1113 query = iq.addElement(('jabber:iq:register', 'query')) | |
1114 _user = query.addElement('username') | |
1115 _user.addContent(self.user_login) | |
1116 _pass = query.addElement('password') | |
1117 _pass.addContent(self.user_pass) | |
1118 if self.user_email: | |
1119 _email = query.addElement('email') | |
1120 _email.addContent(self.user_email) | |
1121 d = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) | |
1122 d.chainDeferred(self.deferred) | |
1123 | |
1124 def registrationAnswer(self, answer): | |
1125 log.debug(_(u"Registration answer: %s") % answer.toXml()) | |
1126 self.xmlstream.sendFooter() | |
1127 | |
1128 def registrationFailure(self, failure_): | |
1129 log.info(_("Registration failure: %s") % unicode(failure_.value)) | |
1130 self.xmlstream.sendFooter() | |
1131 raise failure_.value | |
1132 | |
1133 | |
1134 class SatVersionHandler(generic.VersionHandler): | 1093 class SatVersionHandler(generic.VersionHandler): |
1135 | 1094 |
1136 def getDiscoInfo(self, requestor, target, node): | 1095 def getDiscoInfo(self, requestor, target, node): |
1137 #XXX: We need to work around wokkel's behaviour (namespace not added if there is a | 1096 #XXX: We need to work around wokkel's behaviour (namespace not added if there is a |
1138 # node) as it cause issues with XEP-0115 & PEP (XEP-0163): there is a node when server | 1097 # node) as it cause issues with XEP-0115 & PEP (XEP-0163): there is a node when server |