# HG changeset patch # User Goffi # Date 1448639651 -3600 # Node ID 9a7a27c4461172e2d9c1f7fa1d56107a0e797e98 # Parent 5a93f13c1e76618592f332a4ff3d79651bb1d0f8 plugin account: fixed profile creation: session is started to set the connection parameters, then stopped diff -r 5a93f13c1e76 -r 9a7a27c44611 src/plugins/plugin_misc_account.py --- a/src/plugins/plugin_misc_account.py Fri Nov 27 16:52:14 2015 +0100 +++ b/src/plugins/plugin_misc_account.py Fri Nov 27 16:54:11 2015 +0100 @@ -159,7 +159,7 @@ def generatePassword(self): """Generate a password with random characters. - + @return unicode """ random.seed() @@ -175,11 +175,12 @@ @param email (unicode): where to send to confirmation email to @param password (unicode): password chosen by the user + while be used for profile *and* XMPP account @param jid_s (unicode): JID to re-use or to register: - non empty value: bind this JID to the new sat profile - None or "": register a new JID on the local XMPP server @param profile - @return Deferred + @return Deferred """ if not password or not profile: raise exceptions.DataError @@ -214,13 +215,15 @@ def setParams(dummy): self.host.memory.setParam("JabberID", jid_s, "Connection", profile_key=profile) d = self.host.memory.setParam("Password", password, "Connection", profile_key=profile) - return d.addCallback(lambda dummy: self.host.memory.auth_sessions.profileDelUnique(profile)) + return d def removeProfile(failure): self.host.memory.asyncDeleteProfile(profile) return failure + d.addCallback(lambda dummy: self.host.memory.startSession(password, profile)) d.addCallback(setParams) + d.addCallback(lambda dummy: self.host.memory.stopSession(profile)) d.addErrback(removeProfile) return d @@ -515,12 +518,12 @@ def asyncConnectWithXMPPCredentials(self, jid_s, password): """Create and connect a new SàT profile using the given XMPP credentials. - + Re-use given JID and XMPP password for the profile name and profile password. @param jid_s (unicode): JID @param password (unicode): XMPP password @return Deferred(bool) - @raise exceptions.PasswordError, exceptions.ConflictError + @raise exceptions.PasswordError, exceptions.ConflictError """ try: # be sure that the profile doesn't exist yet self.host.memory.getProfileName(jid_s) @@ -536,7 +539,7 @@ def removeProfile(failure): # profile has been successfully created but the XMPP credentials are wrong! log.debug("Removing previously auto-created profile: %s" % failure.getErrorMessage()) self.host.memory.asyncDeleteProfile(jid_s) - raise failure + raise failure d.addErrback(removeProfile) return d