Skip to content

Commit 27e3040

Browse files
author
Sachin Maheshwari
committed
triggering logout request from iframe
1 parent a3309c0 commit 27e3040

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

web-assets/js/setupAuth0.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const authSetup = function () {
3737
const shouldLogout = qs['logout'];
3838
const regSource = qs['regSource'];
3939
const utmSource = qs['utm_source'];
40+
const loggerMode = "dev";
41+
const IframeLogoutRequestType = "LOGOUT_REQUEST";
4042

4143

4244
var auth0 = null;
@@ -299,11 +301,24 @@ const authSetup = function () {
299301
}
300302
}
301303

304+
function logger(label, message) {
305+
if (loggerMode === "dev") {
306+
console.log(label, message);
307+
}
308+
}
309+
302310
/**
303311
* will receive message from iframe
304312
*/
305313
function receiveMessage(e) {
306-
console.log("received Event:", e);
314+
logger("received Event:", e);
315+
if (e.data && e.data.type && e.origin) {
316+
if (e.data.type === IframeLogoutRequestType) {
317+
host = e.origin;
318+
logout();
319+
}
320+
}
321+
307322
}
308323

309324
init();

0 commit comments

Comments
 (0)