From b9b08feadd572c3e5c0dd04275d3a2c6ce37444b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 7 Aug 2025 17:35:13 +0200 Subject: [PATCH] Added logout overwritte logic for espocrm --- .../templates/logout.js.j2 | 55 ++++++++++++++----- .../templates/logout_one_liner.js.j2 | 12 ++-- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 b/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 index e811937e..b8e98318 100644 --- a/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 +++ b/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 @@ -14,9 +14,16 @@ return str && /(?:^|\W)log\s*out(?:\W|$)|logout/i.test(str); } - function hasLogoutAttribute(el) { - for (const attr of el.attributes) { - if (/logout/i.test(attr.name) || /\/logout/i.test(attr.value)) { + /** + * Returns true if any attribute name or value on the given element + * contains the substring "logout" (case-insensitive). + * + * @param {Element} element – The DOM element to inspect. + * @returns {boolean} – True if "logout" appears in any attribute name or value. + */ + function containsLogoutAttribute(element) { + for (const attribute of element.attributes) { + if (/logout/i.test(attribute.name) || /logout/i.test(attribute.value)) { return true; } } @@ -43,23 +50,41 @@ return false; } - function overrideLogout(el) { + /** + * Apply logout redirect behavior to a matching element: + * – Installs a capturing click‐handler to force navigation to logoutUrl + * – Always sets href/formaction/action to logoutUrl + * – Marks the element as patched to avoid double‐binding + * + * @param {Element} el – The element to override (e.g. ,