core: registerNewAccount partial fix

This commit is contained in:
Goffi 2014-02-04 18:54:06 +01:00
commit eeff94469a
2 changed files with 5 additions and 7 deletions

View file

@ -378,12 +378,12 @@ class SAT(service.Service):
return None return None
return self.profiles[profile].getHostJid() return self.profiles[profile].getHostJid()
def registerNewAccount(self, login, password, email, server, port=5222, id=None, profile_key='@NONE@'): def registerNewAccount(self, login, password, email, server, port=5222, id_=None, profile_key='@NONE@'):
"""Connect to a server and create a new account using in-band registration""" """Connect to a server and create a new account using in-band registration"""
profile = self.memory.getProfileName(profile_key) profile = self.memory.getProfileName(profile_key)
assert(profile) assert(profile)
next_id = id or sat_next_id() # the id is used to send server's answer next_id = id_ or self.get_next_id() # the id is used to send server's answer
serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id, profile)) serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id, profile))
connector = reactor.connectTCP(server, port, serverRegistrer) connector = reactor.connectTCP(server, port, serverRegistrer)
serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect() serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
@ -397,11 +397,9 @@ class SAT(service.Service):
server = self.memory.getParamA("Server", "Connection", profile_key=profile) server = self.memory.getParamA("Server", "Connection", profile_key=profile)
if not user or not password or not server: if not user or not password or not server:
info(_('No user or server given')) raise exceptions.DataError(_("No user, password or server given, can't register new account."))
#TODO: a proper error message must be sent to frontend
self.actionResult(id, "ERROR", {'message': _("No user, password or server given, can't register new account.")}, profile)
return
# FIXME: to be fixed with XMLUI dialogs once their implemented
confirm_id = sat_next_id() confirm_id = sat_next_id()
self.__private_data[confirm_id] = (id, profile) self.__private_data[confirm_id] = (id, profile)

View file

@ -213,7 +213,7 @@ class Params(object):
self.default_profile = None self.default_profile = None
self.params = {} self.params = {}
self.params_gen = {} self.params_gen = {}
host.registerCallback(host.registerNewAccountCB, force_id="registerNewAccount") host.registerCallback(host.registerNewAccountCB, with_data=True, force_id="registerNewAccount")
def createProfile(self, profile): def createProfile(self, profile):
"""Create a new profile """Create a new profile