From bf4c5015ce6c744b0ffb5b350f8b6c10fc11155c Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Tue, 3 Jan 2023 12:31:41 +0000 Subject: [PATCH] [IMP] core: make some cookies expire on logout Some cookies were left around even when the user logged out The next user should log into the default company instead of the company of the last user. task-3077421 closes odoo/odoo#108998 Related: odoo/enterprise#35685 Signed-off-by: Julien Castiaux --- addons/web/models/ir_http.py | 5 +++++ odoo/addons/base/models/ir_http.py | 4 ++++ odoo/http.py | 3 +++ 3 files changed, 12 insertions(+) diff --git a/addons/web/models/ir_http.py b/addons/web/models/ir_http.py index 02287053691..73a0fa7ebc1 100644 --- a/addons/web/models/ir_http.py +++ b/addons/web/models/ir_http.py @@ -58,6 +58,11 @@ class Http(models.AbstractModel): super()._pre_dispatch(rule, args) cls._handle_debug() + @classmethod + def _post_logout(cls): + super()._post_logout() + request.future_response.set_cookie('cids', max_age=0) + def webclient_rendering_context(self): return { 'menu_data': request.env['ir.ui.menu'].load_menus(request.session.debug), diff --git a/odoo/addons/base/models/ir_http.py b/odoo/addons/base/models/ir_http.py index 4c609555a13..672f87b4a04 100644 --- a/odoo/addons/base/models/ir_http.py +++ b/odoo/addons/base/models/ir_http.py @@ -150,6 +150,10 @@ class IrHttp(models.AbstractModel): def _post_dispatch(cls, response): request.dispatcher.post_dispatch(response) + @classmethod + def _post_logout(cls): + pass + @classmethod def _handle_error(cls, exception): return request.dispatcher.handle_error(exception) diff --git a/odoo/http.py b/odoo/http.py index 7f8b92e250f..ff39250c4d3 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -1002,6 +1002,9 @@ class Session(collections.abc.MutableMapping): self.context['lang'] = request.default_lang() if request else DEFAULT_LANG self.should_rotate = True + if request and request.env: + request.env['ir.http']._post_logout() + def touch(self): self.is_dirty = True