[login] fix the redirect url after login (closes #11689118)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Mar 2016 17:13:43 +0100
changeset 11609 cc1d4b66ca26
parent 11608 259fa3391c7b
child 11610 4cac84a8bf5f
[login] fix the redirect url after login (closes #11689118) redirecting to '/' by default after login doesn't work properly when a prefix is used, whether we're sitting behind a PrefixMiddleware or not. To fix this, rely on cubicweb's build_url to turn any relative path into an absolute url.
pyramid_cubicweb/login.py
--- a/pyramid_cubicweb/login.py	Tue Mar 08 16:12:01 2016 +0100
+++ b/pyramid_cubicweb/login.py	Fri Mar 18 17:13:43 2016 +0100
@@ -57,12 +57,13 @@
         request, user_eid,
         persistent=asbool(request.params.get('__setauthcookie', False)))
 
-    new_path = request.params.get('postlogin_path', '/')
+    new_path = request.params.get('postlogin_path', '')
 
     if new_path == 'login':
-        new_path = '/'
+        new_path = ''
 
-    raise HTTPSeeOther(new_path, headers=headers)
+    url = request.cw_request.build_url(new_path)
+    raise HTTPSeeOther(url, headers=headers)
 
 
 @view_config(route_name='login', effective_principals=security.Authenticated)