Skip to content
Snippets Groups Projects
Commit 7124c3a4 authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

When an email address is removed, make sure to remove loggedIn associations

parent 18c7a2f7
No related branches found
No related tags found
No related merge requests found
......@@ -136,6 +136,15 @@ BrowserID.Storage = (function() {
}
}
storage.siteInfo = JSON.stringify(siteInfo);
// remove any logged in sites associated with this address.
var loggedInInfo = JSON.parse(storage.loggedIn || "{}");
for(var site in loggedInInfo) {
if(loggedInInfo[site] === email) {
delete loggedInInfo[site];
}
}
storage.loggedIn = JSON.stringify(loggedInInfo);
}
else {
throw "unknown email address";
......
......@@ -4,7 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function() {
var storage = BrowserID.Storage,
var bid = BrowserID,
storage = bid.Storage,
testHelpers = bid.TestHelpers,
TEST_ORIGIN = "http://test.domain";
module("common/js/storage", {
......@@ -183,11 +185,16 @@
test("setLoggedIn, getLoggedIn, loggedInCount", function() {
var email = "testuser@testuser.com";
storage.addSecondaryEmail(email);
storage.setLoggedIn(TEST_ORIGIN, email);
equal(storage.getLoggedIn(TEST_ORIGIN), email, "correct email");
storage.setLoggedIn("http://another.domain", email);
equal(storage.loggedInCount(), 2, "correct logged in count");
storage.removeEmail(email);
equal(storage.loggedInCount(), 0, "after email removed, not logged in anywhere");
testHelpers.testUndefined(storage.getLoggedIn(TEST_ORIGIN), "sites with email no longer logged in");
});
}());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment