diff --git a/resources/static/common/js/user.js b/resources/static/common/js/user.js index e0783c165f9a89dba843b172c6f0e0a1f2da0948..0f08cc829f64454fe1302919aebee60d508f94eb 100644 --- a/resources/static/common/js/user.js +++ b/resources/static/common/js/user.js @@ -101,7 +101,7 @@ BrowserID.User = (function() { } } - function stageAddressVerification(onComplete, staged) { + function handleStageAddressVerifictionResponse(onComplete, staged) { var status = { success: staged }; if (!staged) status.reason = "throttle"; @@ -349,14 +349,8 @@ BrowserID.User = (function() { * @param {function} [onFailure] - Called on error. */ createSecondaryUser: function(email, password, onComplete, onFailure) { - // set - XXX Use stageAddressVerification to handle the response. - network.createUser(email, password, origin, function(created) { - // Used on the main site when the user verifies - once verification - // is complete, the user is redirected back to the RP and logged in. - var site = User.getReturnTo(); - if (created && site) storage.setReturnTo(site); - complete(onComplete, created); - }, onFailure); + network.createUser(email, password, origin, + handleStageAddressVerifictionResponse.curry(onComplete), onFailure); }, /** @@ -617,7 +611,7 @@ BrowserID.User = (function() { User.isEmailRegistered(email, function(registered) { if (registered) { network.requestPasswordReset(email, password, origin, - stageAddressVerification.curry(onComplete), onFailure); + handleStageAddressVerifictionResponse.curry(onComplete), onFailure); } else if (onComplete) { onComplete({ success: false, reason: "invalid_user" }); @@ -672,7 +666,7 @@ BrowserID.User = (function() { else if (!idInfo.verified) { // this address is unverified, try to reverify it. network.requestEmailReverify(email, origin, - stageAddressVerification.curry(onComplete), onFailure); + handleStageAddressVerifictionResponse.curry(onComplete), onFailure); } }, diff --git a/resources/static/dialog/js/misc/helpers.js b/resources/static/dialog/js/misc/helpers.js index e7626e652c04ea51a24c1938c1e7f64e8a1cc96d..949eac7a2f400aad97af58ff0edca8ffdfc4adef 100644 --- a/resources/static/dialog/js/misc/helpers.js +++ b/resources/static/dialog/js/misc/helpers.js @@ -74,7 +74,7 @@ function createUser(email, password, callback) { var self=this; user.createSecondaryUser(email, password, function(status) { - if (status) { + if (status.success) { var info = { email: email, password: password }; self.publish("user_staged", info, info); complete(callback, true); diff --git a/resources/static/pages/js/signup.js b/resources/static/pages/js/signup.js index d7d4049ba49380eddc94045312655fd0685d1c5f..49677c8e48721f6fb75f3e2a14726716569617be 100644 --- a/resources/static/pages/js/signup.js +++ b/resources/static/pages/js/signup.js @@ -80,7 +80,7 @@ BrowserID.signUp = (function() { if(valid) { user.createSecondaryUser(this.emailToStage, pass, function(status) { - if(status) { + if(status.success) { pageHelpers.emailSent(oncomplete && oncomplete.curry(true)); } else { diff --git a/resources/static/test/cases/common/js/user.js b/resources/static/test/cases/common/js/user.js index 7138f225ab88186a051694319ef2124584a3b0e5..744368369842c22921048e2553e0fa504e42bfe5 100644 --- a/resources/static/test/cases/common/js/user.js +++ b/resources/static/test/cases/common/js/user.js @@ -158,7 +158,7 @@ asyncTest("createSecondaryUser success - callback with true status", function() { lib.createSecondaryUser(TEST_EMAIL, "password", function(status) { - ok(status, "user created"); + ok(status.success, "user created"); start(); }, testHelpers.unexpectedXHRFailure); }); @@ -167,7 +167,10 @@ xhr.useResult("throttle"); lib.createSecondaryUser(TEST_EMAIL, "password", function(status) { - equal(status, false, "user creation refused"); + testObjectValuesEqual(status, { + success: false, + reason: "throttle" + }); start(); }, testHelpers.unexpectedXHRFailure); });