[login] redirect to real instance root if no postlogin_path is provided
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 14 Jun 2012 15:21:12 +0200
changeset 8444 7a861620f64f
parent 8443 86fc11fb6f99
child 8445 594efcf51536
[login] redirect to real instance root if no postlogin_path is provided When not postlogin_path is provided, the login form issue a redirect to "/". The instance root may not be at "/" on the server. Then issuing a redirect to "/" send the user to the wrong location. We now redirect to "." which works fine because the "login" controller a direct children of instance root (http://babar.com/instance/login). All other redirection of the login controller use relative path too and then rely on this relative path from the login controleur to the instance root. This mechanism may be considered fragile and may deserve a proper fix. but this is to be discussed and implemented in another changeset.
web/test/unittest_views_basecontrollers.py
web/views/basecontrollers.py
--- a/web/test/unittest_views_basecontrollers.py	Thu Jun 14 15:55:03 2012 +0200
+++ b/web/test/unittest_views_basecontrollers.py	Thu Jun 14 15:21:12 2012 +0200
@@ -852,7 +852,7 @@
         req = self.request()
         with self.assertRaises(Redirect) as cm:
             self.ctrl_publish(req, ctrl='login')
-        self.assertEqual('/', cm.exception.location)
+        self.assertEqual('.', cm.exception.location)
 
 if __name__ == '__main__':
     unittest_main()
--- a/web/views/basecontrollers.py	Thu Jun 14 15:55:03 2012 +0200
+++ b/web/views/basecontrollers.py	Thu Jun 14 15:21:12 2012 +0200
@@ -90,9 +90,7 @@
 
     def publish(self, rset=None):
         """log in the instance"""
-        path = self._cw.form.get('postlogin_path')
-        if not path:
-            path = '/'
+        path = self._cw.form.get('postlogin_path', '.')
         raise Redirect(path)