plugin misc_account: suppress the profile after its creation if the XMPP account registration failed

This commit is contained in:
souliane 2014-06-19 19:20:52 +02:00
commit 1cd755ac58

View file

@ -174,7 +174,7 @@ class MiscAccount(object):
return d
def _profileRegistered(self, result, email, password, profile):
"""Create the profile and the XMPP account.
"""Create the XMPP account and send the confirmation email.
@param result: result of asyncCreateProfile
@param email: user email
@ -182,20 +182,27 @@ class MiscAccount(object):
@param profile: %(doc_profile)s
@return: a deferred None value when all the processing is done
"""
#FIXME: values must be in a config file instead of hardcoded
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, self.getConfig('new_account_domain'), self.getConfig('new_account_resource')),
"Connection", profile_key=profile)
self.host.memory.setParam("Server", self.getConfig('new_account_server'),
"Connection", profile_key=profile)
self.host.memory.setParam("Password", password,
"Connection", profile_key=profile)
#and the account
# XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
# and just change the password if the account already exists
d = ProsodyRegisterProtocol.prosodyctl(self, 'adduser', password, profile)
d.addCallback(self._sendEmails, profile, email, password)
d.addCallback(lambda ignore: None)
def setParams(dummy):
#FIXME: values must be in a config file instead of hardcoded
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, self.getConfig('new_account_domain'), self.getConfig('new_account_resource')),
"Connection", profile_key=profile)
self.host.memory.setParam("Server", self.getConfig('new_account_server'),
"Connection", profile_key=profile)
self.host.memory.setParam("Password", password,
"Connection", profile_key=profile)
def removeProfile(failure):
self.host.memory.asyncDeleteProfile(profile)
return failure
d.addCallback(setParams)
d.addErrback(removeProfile)
return d
def _sendEmails(self, result, login, email, password):