diff libervia.py @ 415:fadbba1d793f

server_side: added support for SSL and related parameters: Full parameters list: -t, --connection_type= 'http', 'https' or 'both' (to launch both servers). [default: both] -p, --port= The port number to listen HTTP on. [default: 8080] -s, --port_https= The port number to listen HTTPS on. [default: 8443] -c, --ssl_certificate= PEM certificate with both private and public parts. [default: libervia.pem] -r, --redirect_to_https= automatically redirect from HTTP to HTTPS. [default: 0] -w, --security_warning= warn user that he is about to connect on HTTP. [default: 1]
author souliane <souliane@mailoo.org>
date Tue, 18 Mar 2014 15:59:38 +0100
parents ee8ebfe23e16
children 20c508f9b32a
line wrap: on
line diff
--- a/libervia.py	Fri Mar 21 09:20:27 2014 +0100
+++ b/libervia.py	Tue Mar 18 15:59:38 2014 +0100
@@ -309,12 +309,15 @@
     def displayNotification(self, title, body):
         self.notification.notify(title, body)
 
-    def _isRegisteredCB(self, registered):
+    def _isRegisteredCB(self, result):
+        registered, warning = result
         if not registered:
             self._register_box = RegisterBox(self.logged)
             self._register_box.centerBox()
             self._register_box.show()
-            self._tryAutoConnect()
+            if warning:
+                dialog.InfoDialog(_('Security warning'), warning).show()
+            self._tryAutoConnect(skip_validation=not not warning)
         else:
             self._register.call('isConnected', self._isConnectedCB)
 
@@ -357,8 +360,10 @@
             self.bridge.call('asyncGetParamA', lambda value: params_ui_cb(self.params_ui[param], value),
                              self.params_ui[param]['name'], self.params_ui[param]['category'])
 
-    def _tryAutoConnect(self):
-        """This method retrieve the eventual URL parameters to auto-connect the user."""
+    def _tryAutoConnect(self, skip_validation=False):
+        """This method retrieve the eventual URL parameters to auto-connect the user.
+        @param skip_validation: if True, set the form values but do not validate it
+        """
         params = getURLParams(Window.getLocation().getSearch())
         if "login" in params:
             self._register_box._form.login_box.setText(params["login"])
@@ -366,7 +371,8 @@
             if "passwd" in params:
                 # try to connect
                 self._register_box._form.login_pass_box.setText(params["passwd"])
-                self._register_box._form.onLogin(None)
+                if not skip_validation:
+                    self._register_box._form.onLogin(None)
                 return True
             else:
                 # this would eventually set the browser saved password