Skip to content

Commit 13f9fa6

Browse files
committed
[IMP] website: allow to bypass the website domain redirection
When we go to the website preview in the Odoo backend, if the current domain used (to access the backend) is not the same as the one of the previewed website, we redirect the user, and he might have to reconnect. The same is done when using the website switcher. Note: in the first case, the user is warned. We should probably do the same for the second case (?). This is a problem for the Odoo support team. When they connect to a customer database upon user request, the <customer_db_name>.odoo.com address is used. But as soon as they are using the website app, they are redirected to the real website domains... where they are disconnected and cannot connect themselves. To fix this issue, we allow setting up a session info parameter to bypass those website redirections. This is not to be done by real users: this will come with bugs (for the support team). Indeed, we are normally redirecting for a reason: many flows rely on using the right domain when visiting a specific website. Depending on what users have in their page, this could also simply make the website preview iframe crash. task-4069779 closes odoo#193122 Signed-off-by: Quentin Smetz (qsm) <[email protected]>
1 parent ce6984d commit 13f9fa6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

addons/website/static/src/client_actions/website_preview/website_preview.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { registry } from '@web/core/registry';
44
import { useService, useBus } from '@web/core/utils/hooks';
55
import core from 'web.core';
6+
import { session } from "@web/session";
67
import { AceEditorAdapterComponent } from '../../components/ace_editor/ace_editor';
78
import { WebsiteEditorComponent } from '../../components/editor/editor';
89
import { WebsiteTranslator } from '../../components/translator/translator';
@@ -57,7 +58,9 @@ export class WebsitePreview extends Component {
5758
this.backendWebsiteId = unslugHtmlDataObject(backendWebsiteRepr).id;
5859

5960
const encodedPath = encodeURIComponent(this.path);
60-
if (this.websiteDomain && !wUtils.isHTTPSorNakedDomainRedirection(this.websiteDomain, window.location.origin)) {
61+
if (!session.website_bypass_domain_redirect // Used by the Odoo support (bugs to be expected)
62+
&& this.websiteDomain
63+
&& !wUtils.isHTTPSorNakedDomainRedirection(this.websiteDomain, window.location.origin)) {
6164
// The website domain might be the naked one while the naked one
6265
// is actually redirecting to `www` (or the other way around).
6366
// In such a case, we need to consider those 2 from the same

addons/website/static/src/systray_items/website_switcher.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { registry } from "@web/core/registry";
55
import { useService } from "@web/core/utils/hooks";
66
import { Dropdown } from "@web/core/dropdown/dropdown";
77
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
8+
import { session } from "@web/session";
89
import wUtils from 'website.utils';
910

1011
const { Component } = owl;
@@ -28,7 +29,11 @@ export class WebsiteSwitcherSystray extends Component {
2829
tooltipPosition: 'left',
2930
}),
3031
callback: () => {
31-
if (website.domain && !wUtils.isHTTPSorNakedDomainRedirection(website.domain, window.location.origin)) {
32+
// TODO share this condition with the website_preview somehow
33+
// -> we should probably show the redirection warning here too
34+
if (!session.website_bypass_domain_redirect // Used by the Odoo support (bugs to be expected)
35+
&& website.domain
36+
&& !wUtils.isHTTPSorNakedDomainRedirection(website.domain, window.location.origin)) {
3237
const { location: { pathname, search, hash } } = this.websiteService.contentWindow;
3338
const path = pathname + search + hash;
3439
window.location.href = `${website.domain}/web#action=website.website_preview&path=${encodeURIComponent(path)}&website_id=${encodeURIComponent(website.id)}`;

0 commit comments

Comments
 (0)