PM-5384 - Refactor duo redirect connector to use messaging to communicate with browser extension similar to SSO process as BroadcastChannel can only communication on same origins (not web to browser extension). (#7736)
This commit is contained in:
parent
3a9dead640
commit
faabb3bbe9
|
@ -8,12 +8,22 @@ window.addEventListener("load", () => {
|
||||||
const client = getQsParam("client");
|
const client = getQsParam("client");
|
||||||
const code = getQsParam("code");
|
const code = getQsParam("code");
|
||||||
|
|
||||||
if (client === "browser" || client === "web") {
|
if (client === "web") {
|
||||||
const channel = new BroadcastChannel("duoResult");
|
const channel = new BroadcastChannel("duoResult");
|
||||||
|
|
||||||
channel.postMessage({ code: code });
|
channel.postMessage({ code: code });
|
||||||
channel.close();
|
channel.close();
|
||||||
|
|
||||||
|
processAndDisplayHandoffMessage();
|
||||||
|
} else if (client === "browser") {
|
||||||
|
window.postMessage({ command: "duoResult", code: code }, "*");
|
||||||
|
processAndDisplayHandoffMessage();
|
||||||
|
} else if (client === "mobile" || client === "desktop") {
|
||||||
|
document.location.replace(mobileDesktopCallback + "?code=" + encodeURIComponent(code));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function processAndDisplayHandoffMessage() {
|
||||||
const handOffMessage = ("; " + document.cookie)
|
const handOffMessage = ("; " + document.cookie)
|
||||||
.split("; duoHandOffMessage=")
|
.split("; duoHandOffMessage=")
|
||||||
.pop()
|
.pop()
|
||||||
|
@ -30,7 +40,4 @@ window.addEventListener("load", () => {
|
||||||
p.innerText = handOffMessage;
|
p.innerText = handOffMessage;
|
||||||
|
|
||||||
content.appendChild(p);
|
content.appendChild(p);
|
||||||
} else if (client === "mobile" || client === "desktop") {
|
}
|
||||||
document.location.replace(mobileDesktopCallback + "?code=" + encodeURIComponent(code));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue