[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.
--- 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)