--- a/cubicweb/pyramid/login.py Fri Nov 18 10:28:41 2016 +0100
+++ b/cubicweb/pyramid/login.py Fri Jan 13 11:36:51 2017 +0100
@@ -81,5 +81,13 @@
def includeme(config):
""" Create the 'login' route ('/login') and load this module views"""
+ cwconfig = config.registry['cubicweb.config']
config.add_route('login', '/login')
+ if cwconfig.get('language-mode') == 'url-prefix':
+ config.add_route('login-lang', '/{lang}/login')
+ config.add_view(login_already_loggedin, route_name='login-lang',
+ effective_principals=security.Authenticated)
+ config.add_view(login_form, route_name='login-lang')
+ config.add_view(login_password_login, route_name='login-lang',
+ request_param=('__login', '__password'))
config.scan('cubicweb.pyramid.login')
--- a/cubicweb/pyramid/test/test_login.py Fri Nov 18 10:28:41 2016 +0100
+++ b/cubicweb/pyramid/test/test_login.py Fri Jan 13 11:36:51 2017 +0100
@@ -3,8 +3,25 @@
from cubicweb.pyramid.test import PyramidCWTest
+class LoginTestLangUrlPrefix(PyramidCWTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(LoginTestLangUrlPrefix, cls).setUpClass()
+ cls.config.global_set_option('language-mode', 'url-prefix')
+
+ def test_login_password_login_lang_prefix(self):
+ res = self.webapp.post('/fr/login', {
+ '__login': self.admlogin, '__password': self.admpassword})
+ self.assertEqual(res.status_int, 303)
+
+ res = self.webapp.get('/fr/login')
+ self.assertEqual(res.status_int, 303)
+
+
class LoginTest(PyramidCWTest):
+
def test_login_form(self):
res = self.webapp.get('/login')
self.assertIn('__login', res.text)