From 2ad04ecb471ee396db2034ba87b7bca0e3c39f90 Mon Sep 17 00:00:00 2001 From: cstns Date: Mon, 23 Sep 2024 17:35:32 +0300 Subject: [PATCH] intercept logout click and emit logout event when editor is embedded --- lib/theme/common/forge-common.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/theme/common/forge-common.js b/lib/theme/common/forge-common.js index 292a2ae..3114e36 100644 --- a/lib/theme/common/forge-common.js +++ b/lib/theme/common/forge-common.js @@ -26,6 +26,18 @@ navigateTo(url) }) } + const interceptLogOutClick = (url) => { + document.querySelector('#usermenu-item-logout') + .addEventListener('click', (e) => { + e.preventDefault() + e.stopPropagation() + if (context.shouldEmitInsteadOfRedirect) { + window.parent.postMessage({ + type: 'logout' + }, '*') + } + }) + } function changeFavicon (src) { const link = document.createElement('link') @@ -102,7 +114,7 @@ } }) } - + interceptLogOutClick() interceptLogoClick(projectURL) }) })