|
|
|
@ -268,12 +268,22 @@ |
|
|
|
|
window.document.getElementById("app").style["display"] = "none"; |
|
|
|
|
let origin = window.location.origin; |
|
|
|
|
let encoded_origin = encodeURIComponent(origin); |
|
|
|
|
let port; |
|
|
|
|
|
|
|
|
|
const init = () => { |
|
|
|
|
if (net_auth_iframe && port) |
|
|
|
|
net_auth_iframe.postMessage({ method: "init", session:value, manifest:{origin:origin_url}, port: port }, iframe_config.origin, [port]); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
iframe.addEventListener("load", function() { |
|
|
|
|
net_auth_iframe = this.contentWindow; |
|
|
|
|
//console.log(net_auth_iframe); |
|
|
|
|
init(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const ready_handler = async function(m) { |
|
|
|
|
//console.log("got message from", m.origin, m.data, iframe_config.origin); |
|
|
|
|
if (m.data.ready && m.origin === iframe_config.origin) { |
|
|
|
|
//console.log("got ready message from", m.origin); |
|
|
|
|
//remove this listener |
|
|
|
|
window.removeEventListener("message",ready_handler); |
|
|
|
|
const { port1, port2 } = new MessageChannel(); |
|
|
|
@ -316,15 +326,16 @@ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
port = port2; |
|
|
|
|
init(); |
|
|
|
|
//console.log("sending init message to app-auth"); |
|
|
|
|
net_auth_iframe.postMessage({ method: "init", session:value, manifest:{origin:origin_url}, port: port2 }, iframe_config.origin, [port2]); |
|
|
|
|
} else if (m.data.status == "error" && m.origin === iframe_config.origin) { |
|
|
|
|
console.error(m.data.error); |
|
|
|
|
window.location.href = origin_url; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
window.addEventListener("message",ready_handler); |
|
|
|
|
}); |
|
|
|
|
iframe.src = `${iframe_config.src}${encoded_origin}`; |
|
|
|
|
} else if (logged_in) { |
|
|
|
|
// we redirect to the unauthenticated origin |
|
|
|
|