plugin misc_account: suppress the profile after its creation if the XMPP account registration failed
This commit is contained in:
parent
ab67b9cf85
commit
1cd755ac58
1 changed files with 17 additions and 10 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue