diff src/server/server.py @ 464:bea9788f3170

browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback: - TODO: allow the user to set another XMPP password with the stdui action CHANGE_XMPP_PASSWD_ID
author souliane <souliane@mailoo.org>
date Fri, 23 May 2014 10:00:16 +0200
parents 07433bd892ee
children 33ec27ef4b6a
line wrap: on
line diff
--- a/src/server/server.py	Wed Jun 04 01:27:11 2014 +0200
+++ b/src/server/server.py	Fri May 23 10:00:16 2014 +0200
@@ -613,10 +613,11 @@
         @param request: request of the register form
         @return: a constant indicating the state:
             - BAD REQUEST: something is wrong in the request (bad arguments)
-            - AUTH ERROR: either the profile (login) or the password is wrong
+            - PROFILE AUTH ERROR: either the profile (login) or the profile password is wrong
+            - XMPP AUTH ERROR: the profile is authenticated but the XMPP password is wrong
             - ALREADY WAITING: a request has already been submitted for this profile
             - server.NOT_DONE_YET: the profile is being processed, the return
-                value will be given by self._logged or self._logginError
+                value will be given by self._logged or auth_eb
         """
         try:
             login_ = request.args['login'][0]
@@ -630,15 +631,23 @@
         profile_check = self.sat_host.bridge.getProfileName(login_)
         if not profile_check or profile_check != login_ or not password_:
             # profiles with empty passwords are restricted to local frontends
-            return "AUTH ERROR"
+            return "PROFILE AUTH ERROR"
 
         if login_ in self.profiles_waiting:
             return "ALREADY WAITING"
 
-        def auth_eb(ignore=None):
+        def auth_eb(failure):
+            fault = failure.value.faultString
             self.__cleanWaiting(login_)
-            log.info("Profile %s doesn't exist or the submitted password is wrong" % login_)
-            request.write("AUTH ERROR")
+            if fault == 'PasswordError':
+                log.info("Profile %s doesn't exist or the submitted password is wrong" % login_)
+                request.write("PROFILE AUTH ERROR")
+            elif fault == 'SASLAuthError':
+                log.info("The XMPP password of profile %s is wrong" % login_)
+                request.write("XMPP AUTH ERROR")
+            else:
+                log.error('Unmanaged fault string %s in errback for the connection of profile %s' % (fault, login_))
+                request.write('UNMANAGED FAULT STRING: %s' % str(fault))
             request.finish()
 
         self.profiles_waiting[login_] = request
@@ -731,13 +740,6 @@
         request.write('LOGGED')
         request.finish()
 
-    def _logginError(self, login, request, error_type):
-        """Something went wrong during logging in
-        @return: error
-        """
-        self.__cleanWaiting(login)
-        return error_type
-
     def jsonrpc_isConnected(self):
         _session = self.request.getSession()
         profile = ISATSession(_session).profile
@@ -874,16 +876,6 @@
                 self.queue[profile] = []
             self.queue[profile].append(("disconnected",))
 
-    def connectionError(self, error_type, profile):
-        assert(self.register)  # register must be plugged
-        request = self.register.getWaitingRequest(profile)
-        if request:  # The user is trying to log in
-            if error_type == "AUTH_ERROR":
-                _error_t = "AUTH ERROR"
-            else:
-                _error_t = "UNKNOWN"
-            self.register._logginError(profile, request, _error_t)
-
     def render(self, request):
         """
         Render method wich reject access if user is not identified
@@ -1065,7 +1057,6 @@
         def backendReady(dummy):
             self.bridge.register("connected", self.signal_handler.connected)
             self.bridge.register("disconnected", self.signal_handler.disconnected)
-            self.bridge.register("connectionError", self.signal_handler.connectionError)
             self.bridge.register("actionResult", self.action_handler.actionResultCb)
             #core
             for signal_name in ['presenceUpdate', 'newMessage', 'subscribe', 'contactDeleted', 'newContact', 'entityDataUpdated', 'askConfirmation', 'newAlert', 'paramUpdate']: