[FIX] completely destroy the current openerp session on logout (but leave the webclie...
authorXavier Morel <xmo@openerp.com>
Fri, 10 Feb 2012 16:43:09 +0000 (17:43 +0100)
committerXavier Morel <xmo@openerp.com>
Fri, 10 Feb 2012 16:43:09 +0000 (17:43 +0100)
lp bug: https://launchpad.net/bugs/925386 fixed

bzr revid: xmo@openerp.com-20120210164309-lyslwm4t94a4jd7g

addons/web/common/http.py
addons/web/common/session.py
addons/web/controllers/main.py
addons/web/static/src/js/chrome.js
addons/web/static/src/js/core.js

index a281cd0..71a280f 100644 (file)
@@ -357,11 +357,13 @@ def session_context(request, storage_path, session_cookie='sessionid'):
         # session id, and are generally noise
         removed_sessions = set()
         for key, value in request.session.items():
-            if (isinstance(value, session.OpenERPSession) 
-                and not value._uid
-                and not value.jsonp_requests
-                and value._creation_time + (60*5) < time.time()  # FIXME do not use a fixed value
-            ):
+            if not isinstance(value, session.OpenERPSession):
+                continue
+            if getattr(value, '_suicide', False) or (
+                        not value._uid
+                    and not value.jsonp_requests
+                    # FIXME do not use a fixed value
+                    and value._creation_time + (60*5) < time.time()):
                 _logger.debug('remove session %s', key)
                 removed_sessions.add(key)
                 del request.session[key]
index 58ef83a..ab486f0 100644 (file)
@@ -36,6 +36,7 @@ class OpenERPSession(object):
         self._uid = False
         self._login = False
         self._password = False
+        self._suicide = False
         self.context = {}
         self.contexts_store = {}
         self.domains_store = {}
index 38fadcf..6f4b76b 100644 (file)
@@ -613,6 +613,10 @@ class Session(openerpweb.Controller):
         req.session.assert_valid()
         return None
 
+    @openerpweb.jsonrequest
+    def destroy(self, req):
+        req.session._suicide = True
+
 def eval_context_and_domain(session, context, domain=None):
     e_context = session.eval_context(context)
     # should we give the evaluated context as an evaluation context to the domain?
index 9fda475..c52a95a 100644 (file)
@@ -1147,12 +1147,14 @@ openerp.web.WebClient = openerp.web.OldWidget.extend(/** @lends openerp.web.WebC
         n.warn.apply(n, arguments);
     },
     on_logout: function() {
-        this.session.session_logout();
-        $(window).unbind('hashchange', this.on_hashchange);
-        this.do_push_state({});
-        //would be cool to be able to do this, but I think it will make addons do strange things
-        //this.show_login();
-        window.location.reload();
+        var self = this;
+        this.session.session_logout().then(function () {
+            $(window).unbind('hashchange', self.on_hashchange);
+            self.do_push_state({});
+            //would be cool to be able to do this, but I think it will make addons do strange things
+            //this.show_login();
+            window.location.reload();
+        });
     },
     bind_hashchange: function() {
         $(window).bind('hashchange', this.on_hashchange);
index ba5b2c6..c4e37a8 100644 (file)
@@ -674,6 +674,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
     },
     session_logout: function() {
         this.set_cookie('session_id', '');
+        return this.rpc("/web/session/destroy", {});
     },
     on_session_valid: function() {
     },