Updated layer2 to listen to close request from auth popup

This commit is contained in:
Fabien O'Carroll 2018-12-09 14:00:02 +07:00
parent aec178ee8b
commit b990761136

View File

@ -29,6 +29,16 @@ module.exports = function layer2(options) {
return loadAuth.then(function (frame) {
frame.src = `${authUrl}#${hash}?${query}`;
frame.style.display = 'block';
window.addEventListener('message', function self(event) {
if (event.source !== frame.contentWindow) {
return;
}
if (event.data !== 'pls-close-auth-popup') {
return;
}
window.removeEventListener('message', self);
frame.style.display = 'none';
})
return frame;
});
}