From 5ddd5fb6279521ad08afd3dc2851e9775af018d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@tiolive.com>
Date: Thu, 12 Mar 2015 09:46:24 +0000
Subject: [PATCH] erp5_web: First draft managing Balancer Cookie

---
 .../portal_skins/erp5_web/WebSite_login.xml                | 7 ++++---
 .../portal_skins/erp5_web/WebSite_logout.xml               | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_login.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_login.xml
index 36c750e78d..f38ff10545 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_login.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_login.xml
@@ -45,17 +45,18 @@
              came_from python: request.get(\'came_from\') or request.get(\'field_came_from\');\n
              isAnon here/portal_membership/isAnonymousUser|nothing;">\n
     <tal:block tal:condition="isAnon">\n
-      <tal:block tal:define="dummy python: response.expireCookie(\'__ac\', path=\'/\');\n
+      <tal:block tal:define="dummy python: response.expireCookie(request.getHeader(\'HTTP_X_BALANCER_CURRENT_COOKIE\', \'\'), path=\'/\');\n
+                 dummy python: response.expireCookie(\'__ac\', path=\'/\');\n
                  url python: \'%s/login_form?portal_status_message=%s\' % (here.absolute_url(), here.Base_translateString(\'Login and/or password is incorrect.\'));\n
                  url python: came_from and  \'%s&amp;came_from=%s\' % (url, came_from) or url;\n
                  dummy python: response.redirect(url);" />\n
     </tal:block>\n
     <tal:block tal:condition="not: isAnon">\n
+      <tal:block tal:define="dummy python: response.setCookie(request.getHeader(\'HTTP_X_BALANCER_CURRENT_COOKIE\', \'\'), request.getHeader(\'HTTP_X_BALANCER_CURRENT_SERVER\', \'\'), path=\'/\');" />\n
       <tal:block tal:define="dummy python: response.redirect(came_from or here.getPermanentURL(here));" />\n
     </tal:block>\n
   </tal:block>\n
-</tal:block>\n
-
+</tal:block>
 
 ]]></unicode> </value>
         </item>
diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_logout.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_logout.xml
index ed2873aa75..4bc5abc1b5 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_logout.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_logout.xml
@@ -177,6 +177,10 @@ website = context.getWebSiteValue()\n
 REQUEST = context.REQUEST\n
 if REQUEST.has_key(\'portal_skin\'):\n
    context.portal_skins.clearSkinCookie()\n
+\n
+balancer_cookie = REQUEST.getHeader(\'HTTP_X_BALANCER_CURRENT_COOKIE\', \'\')\n
+if balancer_cookie:\n
+  REQUEST.RESPONSE.expireCookie(balancer_cookie, path=\'/\')\n
 REQUEST.RESPONSE.expireCookie(\'__ac\', path=\'/\')\n
 msg = context.Base_translateString(\'You have been logged out. Thank you for using this website.\')\n
 return website.Base_redirect(form_id, keep_items = {\'portal_status_message\' : msg},  **kw)\n
-- 
2.30.9