# HG changeset patch # User Christophe de Vienne # Date 1411051915 -7200 # Node ID ca3412269cd18ad8775dbbba3f7f450f3c9b1846 # Parent ef8b9021b47b0998b1e967389501230f266cd556 Handle '__setauthcookie' '__setauthcookie' is a form parameter added by the 'rememberme' cube. If present and equals to '1', the cookie max_age will be set to 7 days instead of being a session cookie. To make sure the auth cookie is renewed, the reissue_time is set to 1h. diff -r ef8b9021b47b -r ca3412269cd1 pyramid_cubicweb/defaults.py --- a/pyramid_cubicweb/defaults.py Thu Sep 18 15:07:02 2014 +0200 +++ b/pyramid_cubicweb/defaults.py Thu Sep 18 16:51:55 2014 +0200 @@ -28,7 +28,8 @@ config.set_authentication_policy( AuthTktAuthenticationPolicy( - secret, callback=get_principals, hashalg='sha512')) + secret, callback=get_principals, hashalg='sha512', + reissue_time=3600)) config.set_authorization_policy(ACLAuthorizationPolicy()) config.include('pyramid_cubicweb.login') diff -r ef8b9021b47b -r ca3412269cd1 pyramid_cubicweb/login.py --- a/pyramid_cubicweb/login.py Thu Sep 18 15:07:02 2014 +0200 +++ b/pyramid_cubicweb/login.py Thu Sep 18 16:51:55 2014 +0200 @@ -33,7 +33,10 @@ del request.cw_request.post['__password'] return login_form(request) - headers = security.remember(request, user_eid) + max_age = None + if request.params.get('__setauthcookie') == '1': + max_age = '604800' + headers = security.remember(request, user_eid, max_age=max_age) new_path = request.params.get('postlogin_path', '/')