Skip to content
Snippets Groups Projects
Commit 8511aa83 authored by Sean McArthur's avatar Sean McArthur
Browse files

Merge pull request #2390 from mozilla/issue_2389_loggedIn_after_logout

When an email address is removed, make sure to remove loggedIn associations
parents 1da88b7b 7124c3a4
No related branches found
No related tags found
No related merge requests found
...@@ -136,6 +136,15 @@ BrowserID.Storage = (function() { ...@@ -136,6 +136,15 @@ BrowserID.Storage = (function() {
} }
} }
storage.siteInfo = JSON.stringify(siteInfo); 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 { else {
throw "unknown email address"; throw "unknown email address";
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function() { (function() {
var storage = BrowserID.Storage, var bid = BrowserID,
storage = bid.Storage,
testHelpers = bid.TestHelpers,
TEST_ORIGIN = "http://test.domain"; TEST_ORIGIN = "http://test.domain";
module("common/js/storage", { module("common/js/storage", {
...@@ -183,11 +185,16 @@ ...@@ -183,11 +185,16 @@
test("setLoggedIn, getLoggedIn, loggedInCount", function() { test("setLoggedIn, getLoggedIn, loggedInCount", function() {
var email = "testuser@testuser.com"; var email = "testuser@testuser.com";
storage.addSecondaryEmail(email);
storage.setLoggedIn(TEST_ORIGIN, email); storage.setLoggedIn(TEST_ORIGIN, email);
equal(storage.getLoggedIn(TEST_ORIGIN), email, "correct email"); equal(storage.getLoggedIn(TEST_ORIGIN), email, "correct email");
storage.setLoggedIn("http://another.domain", email); storage.setLoggedIn("http://another.domain", email);
equal(storage.loggedInCount(), 2, "correct logged in count"); 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