changeset 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 b62c1cf0dbf7
children 33ec27ef4b6a
files src/browser/menu.py src/browser/register.py src/server/server.py
diffstat 3 files changed, 26 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/menu.py	Wed Jun 04 01:27:11 2014 +0200
+++ b/src/browser/menu.py	Fri May 23 10:00:16 2014 +0200
@@ -243,7 +243,7 @@
             if not xmlui:
                 return
             body = XMLUI(self.host, xmlui)
-            _dialog = dialog.GenericDialog("Manage your XMPP account", body, options=['NO_CLOSE'])
+            _dialog = dialog.GenericDialog("Manage your account", body, options=['NO_CLOSE'])
             body.setCloseCb(_dialog.close)
             _dialog.show()
         self.host.bridge.call('getAccountDialogUI', gotUI)
--- a/src/browser/register.py	Wed Jun 04 01:27:11 2014 +0200
+++ b/src/browser/register.py	Fri May 23 10:00:16 2014 +0200
@@ -208,17 +208,20 @@
 
     def onSubmitComplete(self, event):
         result = event.getResults()
-        if result == "AUTH ERROR":
-            Window.alert('Your login and/or password is incorrect. Please try again')
+        if result == "PROFILE AUTH ERROR":
+            Window.alert(_('Your login and/or password is incorrect. Please try again'))
+        elif result == "XMPP AUTH ERROR":
+            # TODO: call stdui action CHANGE_XMPP_PASSWD_ID as it's done in primitivus
+            Window.alert(_(u'Your SàT profile has been authenticated but the associated XMPP account failed to connect. Please use another SàT frontend to set another XMPP password.'))
         elif result == "LOGGED":
             self.callback()
         elif result == "SESSION_ACTIVE":
-            Window.alert('Session already active, this should not happen, please contact the author to fix it')
+            Window.alert(_('Session already active, this should not happen, please contact the author to fix it'))
         elif result == "ALREADY EXISTS":
-            self.register_warning_msg.setHTML('This login already exists,<br>please choose another one')
+            self.register_warning_msg.setHTML(_('This login already exists,<br>please choose another one'))
             self.register_warning_msg.setVisible(True)
         elif result == "INTERNAL":
-            self.register_warning_msg.setHTML('SERVER ERROR: something went wrong during registration process, please contact the server administrator')
+            self.register_warning_msg.setHTML(_('SERVER ERROR: something went wrong during registration process, please contact the server administrator'))
             self.register_warning_msg.setVisible(True)
         elif result == "REGISTRATION":
             self.login_warning_msg.setVisible(False)
@@ -230,9 +233,9 @@
             self.email_box.setText('')
             self.right_side.selectTab(0)
             self.login_pass_box.setFocus(True)
-            Window.alert('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO')
+            Window.alert(_('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO'))
         else:
-            Window.alert('Submit error: %s' % result)
+            Window.alert(_('Submit error: %s' % result))
 
 
 class RegisterBox(PopupPanel):
--- 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']: