From e9e115409e4aeb20cbb488552ccecc12870c0d63 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Thu, 8 Mar 2012 14:25:39 -0700 Subject: [PATCH] when setLoggedInUser is used, surpress events when the site's notion of a logged in user is the same as that of browserid --- example/rp/index.html | 3 --- resources/static/communication_iframe/start.js | 13 +++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/example/rp/index.html b/example/rp/index.html index 9eb54b108..739df4783 100644 --- a/example/rp/index.html +++ b/example/rp/index.html @@ -143,9 +143,6 @@ $(document).ready(function() { requiredEmail: requiredEmail }); }); - - // explicitly trigger events at document load - navigator.id.setLoggedInUser(null); }); </script> diff --git a/resources/static/communication_iframe/start.js b/resources/static/communication_iframe/start.js index 1737dff67..4d9de7afb 100644 --- a/resources/static/communication_iframe/start.js +++ b/resources/static/communication_iframe/start.js @@ -39,8 +39,17 @@ setRemoteOrigin(trans.origin); user.getSilentAssertion(loggedInUser, function(email, assertion) { - if (email && assertion) chan.notify({ method: 'login', params: assertion }); - else chan.notify({ method: 'logout' }); + if (email) { + // only send login events when the assertion is defined - when + // the 'loggedInUser' is already logged in, it's false - that is + // when the site already has the user logged in and does not want + // the resources or cost required to generate an assertion + if (assertion) chan.notify({ method: 'login', params: assertion }); + } else if (loggedInUser !== null) { + // only send logout events when loggedInUser is not null, which is an + // indicator that the site thinks the user is logged out + chan.notify({ method: 'logout' }); + } }, function(err) { chan.notify({ method: 'logout' }); }); -- GitLab