changeset 1696:9a7a27c44611

plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
author Goffi <goffi@goffi.org>
date Fri, 27 Nov 2015 16:54:11 +0100
parents 5a93f13c1e76
children 52af44e745b5
files src/plugins/plugin_misc_account.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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