core: added email in registerNewAccount
This commit is contained in:
parent
38f45e43d4
commit
138f0b26da
2 changed files with 33 additions and 57 deletions
|
|
@ -265,11 +265,11 @@ class SAT(service.Service):
|
|||
return None
|
||||
return self.profiles[profile]
|
||||
|
||||
def registerNewAccount(self, login, password, server, port = 5222, id = None):
|
||||
def registerNewAccount(self, login, password, email, server, port = 5222, id = None):
|
||||
"""Connect to a server and create a new account using in-band registration"""
|
||||
|
||||
next_id = id or sat_next_id() #the id is used to send server's answer
|
||||
serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, next_id))
|
||||
serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id))
|
||||
connector = reactor.connectTCP(server, port, serverRegistrer)
|
||||
serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ class SAT(service.Service):
|
|||
user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
|
||||
password = self.memory.getParamA("Password", "Connection", profile_key=profile)
|
||||
server = self.memory.getParamA("Server", "Connection", profile_key=profile)
|
||||
self.registerNewAccount(user, password, server, id=action_id)
|
||||
self.registerNewAccount(user, password, None, server, id=action_id)
|
||||
else:
|
||||
self.actionResult(action_id, "SUPPRESS", {})
|
||||
|
||||
|
|
|
|||
|
|
@ -236,12 +236,13 @@ class SatFallbackHandler(generic.FallbackHandler):
|
|||
|
||||
class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
||||
|
||||
def __init__(self, host, jabber_host, user_login, user_pass, answer_id):
|
||||
def __init__(self, host, jabber_host, user_login, user_pass, email, answer_id):
|
||||
xmlstream.ConnectAuthenticator.__init__(self, jabber_host)
|
||||
self.host = host
|
||||
self.jabber_host = jabber_host
|
||||
self.user_login = user_login
|
||||
self.user_pass = user_pass
|
||||
self.user_email = email
|
||||
self.answer_id = answer_id
|
||||
print _("Registration asked for"),user_login, user_pass, jabber_host
|
||||
|
||||
|
|
@ -258,6 +259,10 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
|||
_user.addContent(self.user_login)
|
||||
_pass = query.addElement('password')
|
||||
_pass.addContent(self.user_pass)
|
||||
if self.user_email:
|
||||
_email = query.addElement('email')
|
||||
_email.addContent(self.user_email)
|
||||
print iq.toXml()
|
||||
reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure)
|
||||
|
||||
def registrationAnswer(self, answer):
|
||||
|
|
|
|||
Loading…
Reference in a new issue