# HG changeset patch # User souliane # Date 1403198452 -7200 # Node ID f25ec9fd7cc4dc697af8c08de53dd3653296ec0f # Parent c0ef97002ef4bcd176f61cd0530e606a85bbba2b plugin misc_account: suppress the profile after its creation if the XMPP account registration failed diff -r c0ef97002ef4 -r f25ec9fd7cc4 src/plugins/plugin_misc_account.py --- a/src/plugins/plugin_misc_account.py Wed Jun 18 16:35:20 2014 +0200 +++ b/src/plugins/plugin_misc_account.py Thu Jun 19 19:20:52 2014 +0200 @@ -174,7 +174,7 @@ 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 @@ @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):