From 005b24b4f1ad34bf8eefe61799b76d60190dc123 Mon Sep 17 00:00:00 2001 From: jonathanmmm <32403139+jonathanmmm@users.noreply.github.com> Date: Tue, 3 May 2022 00:23:52 +0200 Subject: [PATCH] config parameter forcing iframe, even when using SSO or CAS Signed-off-by: jonathanmmm <32403139+jonathanmmm@users.noreply.github.com> --- src/main.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main.js b/src/main.js index 38ac9096..0f8484c4 100644 --- a/src/main.js +++ b/src/main.js @@ -56,16 +56,19 @@ function onIframeLoad () { } }; - // Watch for the localStorage change that indicates that an SSO sign in is being attempted - // eslint-disable-next-line no-proto - iframe.contentWindow.localStorage.__proto__.setItem = function (...params) { - // It looks like an SSO or CAS login is being attempted - if (params[0] === "mx_sso_hs_url" && iframe.contentWindow.location.hash === "#/login") { - // Kick them to the non-iframed version. A bit jarring but SSO login most likely won't work in the iframe. - window.location.href = generateUrl('/apps/riotchat/riot/#/login'); - } - window.localStorage.setItem.apply(this, params); - }; + // Setting sso_force_iframe (in config) to false forces iframe even if using SSO or CAS login + if (loadState('riotchat', 'sso_force_iframe') !== false) { + // Watch for the localStorage change that indicates that an SSO sign in is being attempted + // eslint-disable-next-line no-proto + iframe.contentWindow.localStorage.__proto__.setItem = function (...params) { + // It looks like an SSO or CAS login is being attempted + if (params[0] === "mx_sso_hs_url" && iframe.contentWindow.location.hash === "#/login") { + // Kick them to the non-iframed version. A bit jarring but SSO login most likely won't work in the iframe. + window.location.href = generateUrl('/apps/riotchat/riot/#/login'); + } + window.localStorage.setItem.apply(this, params); + }; + } } function iframeHashChanged () { @@ -77,3 +80,4 @@ function iframeHashChanged () { function setTitle () { document.title = iframe.contentWindow.document.title + " - " + originalTitle; } +