Skip to content

Commit

Permalink
config parameter forcing iframe, even when using SSO or CAS
Browse files Browse the repository at this point in the history
Signed-off-by: jonathanmmm <32403139+jonathanmmm@users.noreply.github.com>
  • Loading branch information
jonathanmmm committed May 2, 2022
1 parent 5b10eed commit 5d62585
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 5d62585

Please sign in to comment.