diff --git a/lib/wsapi/user_creation_status.js b/lib/wsapi/user_creation_status.js index e6812c9c26bd722aef6f17f074b04bffaff1402c..41852b7278743be2cea352787e48fd2aaa471b72 100644 --- a/lib/wsapi/user_creation_status.js +++ b/lib/wsapi/user_creation_status.js @@ -19,7 +19,7 @@ exports.process = function(req, res) { if (wsapi.isAuthed(req, 'assertion')) { db.userOwnsEmail(req.session.userid, email, function(err, owned) { if (err) wsapi.databaseDown(res, err); - else if (owned) res.json({ status: 'complete' }); + else if (owned) res.json({ status: 'complete', userid: req.session.userid }); else notAuthed(); }); } else { diff --git a/resources/static/shared/network.js b/resources/static/shared/network.js index 676e60dca18c131873236167ea5dfa4280525c3c..656dcfa139855458ab2e9f5df3c1b6726fc40159 100644 --- a/resources/static/shared/network.js +++ b/resources/static/shared/network.js @@ -257,6 +257,9 @@ BrowserID.Network = (function() { get({ url: "/wsapi/user_creation_status?email=" + encodeURIComponent(email), success: function(status, textStatus, jqXHR) { + if (status.status === 'complete' && status.userid) { + setUserID(status.userid); + } complete(onComplete, status.status); }, error: onFailure diff --git a/resources/static/shared/storage.js b/resources/static/shared/storage.js index 317fdcd374fa8f93a54815529e3c78d85af23770..6e131ba49703237af34702405d9635bc510cc78f 100644 --- a/resources/static/shared/storage.js +++ b/resources/static/shared/storage.js @@ -293,6 +293,10 @@ BrowserID.Storage = (function() { } function shouldAskUserAboutHerComputer(userid) { + // if any higher level code passes in a non-userid, + // we'll tell them not to ask, triggering ephemeral sessions. + if (typeof userid !== 'number') return false; + // we should ask the user if this is their computer if they were // first seen over a minute ago, if they haven't denied ownership // of this computer in the last 24 hours, and they haven't confirmed diff --git a/resources/static/test/mocks/xhr.js b/resources/static/test/mocks/xhr.js index d18e5a732f0c0cf7346dd54c9a5cc4f1ac90ebf6..7ff902b893270b62b6916fdbff90848cb4a8c4b8 100644 --- a/resources/static/test/mocks/xhr.js +++ b/resources/static/test/mocks/xhr.js @@ -54,7 +54,7 @@ BrowserID.Mocks.xhr = (function() { "post /wsapi/stage_user throttle": 429, "post /wsapi/stage_user ajaxError": undefined, "get /wsapi/user_creation_status?email=registered%40testuser.com pending": { status: "pending" }, - "get /wsapi/user_creation_status?email=registered%40testuser.com complete": { status: "complete" }, + "get /wsapi/user_creation_status?email=registered%40testuser.com complete": { status: "complete", userid: 4 }, "get /wsapi/user_creation_status?email=registered%40testuser.com mustAuth": { status: "mustAuth" }, "get /wsapi/user_creation_status?email=registered%40testuser.com noRegistration": { status: "noRegistration" }, "get /wsapi/user_creation_status?email=registered%40testuser.com ajaxError": undefined,