Skip to content
Snippets Groups Projects
Commit cfd19012 authored by Robin Lejeune (role)'s avatar Robin Lejeune (role)
Browse files

[FIX] website: separate website menu cache for logged in/out users


The website menu is cached for each page, but there is no difference
between the cache of a logged user or of a public user. If you have a
page restricted to logged in users in the menu, this can sometimes lead
to:
(1) the link appearing in the menu even though the visitor is logged out
(because the cache was done when logged in), and
(2) the link not appearing even though the visitor is connected (because
the cache was done when logged out).

While (1) only leads to a 403 error if one clicks on the menu link, (2)
is more annoying as it hides a page that should be shown.

This commit therefore also caches the website menu depending on the
visitor being logged in or not.

Note that the same bug occurs for pages restricted to a specific group.
In these cases however, there is no technical solution as of now. It
should be considered as a limitation.
In such cases, workarounds are possible:
- Going on the "My account" page (by clicking on the username) will
always show the page.
- One could add a snippet on the homepage with a link to the restricted
page, and conditionally display the snippet only for users of that group

Steps to reproduce the bug:
1) Connect as admin, create a new page, open its properties and set its
visibility to 'Signed in', then publish it.
2) Logout, connect as portal
3) Logout, connect as admin
4) Unpublish and republish the page
5) Logout, reconnect as portal
6) Go to the homepage: the new page doesn't appear in the menu
7) Go to 'Contact us': the page reappears in the menu

opw-3445032

closes odoo/odoo#134688

Signed-off-by: default avatarRomain Derie (rde) <rde@odoo.com>
parent cf6c0af4
Branches
Tags
No related merge requests found
......@@ -170,7 +170,10 @@
</xpath>
<xpath expr="//header/t[@t-cache]" position="attributes">
<attribute name="t-cache">xmlid,website</attribute>
<!-- website.is_public_user() is needed for menus having a page with
restricted visibility (only shown to logged in user): public users and
logged in users can't share the menu cache. -->
<attribute name="t-cache">xmlid,website,website.is_public_user()</attribute>
</xpath>
<xpath expr="//header" position="before">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment