Update with PR feedback
This commit is contained in:
parent
79825dfa1d
commit
e5ce080fd3
1 changed files with 85 additions and 86 deletions
|
@ -26,11 +26,11 @@
|
|||
if (!cookie) {
|
||||
callback('changed');
|
||||
} else if (!init) {
|
||||
var req = new XMLHttpRequest(),
|
||||
url = location.href + '/init';
|
||||
var req = new XMLHttpRequest();
|
||||
|
||||
url += '?client_id=' + encodeURIComponent(clientId);
|
||||
url += '&origin=' + encodeURIComponent(origin);
|
||||
var url = location.href + "/init";
|
||||
url += "?client_id=" + encodeURIComponent(clientId);
|
||||
url += "&origin=" + encodeURIComponent(origin);
|
||||
|
||||
req.open('GET', url, true);
|
||||
|
||||
|
@ -64,36 +64,35 @@
|
|||
}
|
||||
}
|
||||
|
||||
function getCookie() {
|
||||
var name = 'KEYCLOAK_SESSION=',
|
||||
ca = document.cookie.split(';'),
|
||||
i = 0,
|
||||
length = ca.length,
|
||||
c = null;
|
||||
|
||||
for (; i < length; i++) {
|
||||
c = ca[i].trim();
|
||||
function getCookie()
|
||||
{
|
||||
var name = 'KEYCLOAK_SESSION=';
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0; i<ca.length; i++)
|
||||
{
|
||||
var c = ca[i].trim();
|
||||
if (c.indexOf(name)===0) return c.substring(name.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function receiveMessage(event) {
|
||||
var origin = event.origin,
|
||||
data = event.data.split(' '),
|
||||
clientId = data[0],
|
||||
sessionState = data[1];
|
||||
|
||||
if (data.length !== 2) {
|
||||
function receiveMessage(event)
|
||||
{
|
||||
var origin = event.origin;
|
||||
var data = event.data.split(' ');
|
||||
if (data.length != 2) {
|
||||
event.source.postMessage('error', origin);
|
||||
}
|
||||
|
||||
var clientId = data[0];
|
||||
var sessionState = data[1];
|
||||
|
||||
checkState(clientId, event.origin, sessionState, function(result) {
|
||||
event.source.postMessage(result, origin);
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('message', receiveMessage, false);
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue