From 44360c5b9b0ed0f955e281d54fe87ccff627d959 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 27 Nov 2015 16:54:11 +0100 Subject: [PATCH] plugin account: fixed profile creation: session is started to set the connection parameters, then stopped --- src/plugins/plugin_misc_account.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/plugin_misc_account.py b/src/plugins/plugin_misc_account.py index be3ff34e..cab949d8 100755 --- a/src/plugins/plugin_misc_account.py +++ b/src/plugins/plugin_misc_account.py @@ -159,7 +159,7 @@ class MiscAccount(object): def generatePassword(self): """Generate a password with random characters. - + @return unicode """ random.seed() @@ -175,11 +175,12 @@ class MiscAccount(object): @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 @@ class MiscAccount(object): 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 @@ http://www.salut-a-toi.org 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 @@ http://www.salut-a-toi.org 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