Permalink
Browse files

Merge branch 'dev' of github.com:mozilla/browserid into dev

  • Loading branch information...
ozten committed Apr 19, 2012
2 parents c82698a + dced8e2 commit 350636a2369fdb02ef0f4a5f64d666bc8a4534c6
View
@@ -9,7 +9,7 @@
"connect": "1.7.2",
"convict": "0.0.6",
"cjson": "0.0.6",
- "client-sessions": "https://github.com/downloads/lloyd/node-client-sessions/d5f06c5.tgz",
+ "client-sessions": "0.0.6",
"connect-cachify": "0.0.9",
"connect-cookie-session": "0.0.2",
"connect-logger-statsd": "0.0.1",
@@ -18,12 +18,13 @@ BrowserID.Modules.CheckRegistration = (function() {
options.required = !!options.required;
self.renderWait("confirm_email", options);
+
self.email = options.email;
self.verifier = options.verifier;
self.verificationMessage = options.verificationMessage;
+ self.required = options.required;
self.click("#back", self.back);
- self.click("#cancel", self.cancel);
Module.sc.start.call(self, options);
},
@@ -46,16 +47,9 @@ BrowserID.Modules.CheckRegistration = (function() {
},
back: function() {
- // XXX this should change to cancelEmailValidation for email, but this
- // will work.
user.cancelUserValidation();
- this.close("cancel_state");
- },
-
- cancel: function() {
- this.close("cancel");
+ this.publish(this.required ? "cancel" : "cancel_state");
}
-
});
return Module;
@@ -249,15 +249,17 @@ BrowserID.State = (function() {
handleState("assertion_generated", function(msg, info) {
self.success = true;
if (info.assertion !== null) {
- if (storage.usersComputer.shouldAsk(network.userid())) {
- // We have to confirm the user's status
- self.assertion_info = info;
- redirectToState("is_this_your_computer", info);
- }
- else {
- storage.setLoggedIn(user.getOrigin(), self.email);
- startAction("doAssertionGenerated", { assertion: info.assertion, email: self.email });
- }
+ user.shouldAskIfUsersComputer(function(shouldAsk) {
+ if (shouldAsk) {
+ // We have to confirm the user's status
+ self.assertion_info = info;
+ redirectToState("is_this_your_computer", info);
+ }
+ else {
+ storage.setLoggedIn(user.getOrigin(), self.email);
+ startAction("doAssertionGenerated", { assertion: info.assertion, email: self.email });
+ }
+ });
}
else {
redirectToState("pick_email");
@@ -15,9 +15,9 @@
<p>
<% if(required) { %>
- <%= gettext('If this is a mistake, just ignore the sent email and <a href="#" id="cancel">cancel</a>.') %>
+ <%= format(gettext('If this is a mistake, just ignore the sent email and <a %s>cancel</a>.'), [' href="#" id="back"']) %>
<% } else { %>
- <%= gettext('If this is a mistake, just ignore the sent email and <a href="#" id="back">use another email address</a>.') %>
+ <%= format(gettext('If this is a mistake, just ignore the sent email and <a %s>use another email address</a>.'), [' href="#" id="back"']) %>
<% } %>
</p>
@@ -15,7 +15,8 @@ BrowserID.User = (function() {
provisioning = bid.Provisioning,
addressCache = {},
primaryAuthCache = {},
- complete = bid.Helpers.complete;
+ complete = bid.Helpers.complete,
+ registrationComplete = false;
function prepareDeps() {
if (!jwk) {
@@ -130,6 +131,11 @@ BrowserID.User = (function() {
addressCache[email].known = true;
}
+ // registrationComplete is used in shouldAskIfUsersComputer to
+ // prevent the user from seeing the "is this your computer" screen if
+ // they just completed a registration.
+ registrationComplete = true;
+
if (onSuccess) {
onSuccess(status);
}
@@ -220,11 +226,13 @@ BrowserID.User = (function() {
if (config.provisioning) {
provisioning = config.provisioning;
}
+
},
reset: function() {
provisioning = BrowserID.Provisioning;
User.resetCaches();
+ registrationComplete = false;
},
resetCaches: function() {
@@ -1152,14 +1160,36 @@ BrowserID.User = (function() {
}
},
+ /**
+ * Check if the user owns the computer
+ * @method isUsersComputer
+ */
isUsersComputer: function(onComplete, onFailure) {
var userID = network.userid();
if(typeof userID !== "undefined") {
complete(onComplete, storage.usersComputer.confirmed(userID));
} else {
complete(onFailure, "user is not authenticated");
}
+ },
+
+ /**
+ * Check whether the user should be asked if this is their computer
+ * @method shouldAskIfUsersComputer
+ */
+ shouldAskIfUsersComputer: function(onComplete, onFailure) {
+ var userID = network.userid();
+ if(typeof userID !== "undefined") {
+ // A user should never be asked if they completed an email
+ // registration/validation in this dialog session.
+ var shouldAsk = storage.usersComputer.shouldAsk(userID)
+ && !registrationComplete;
+ complete(onComplete, shouldAsk);
+ } else {
+ complete(onFailure, "user is not authenticated");
+ }
+ return shouldAsk;
}
};
@@ -13,12 +13,13 @@
testHelpers = bid.TestHelpers,
register = testHelpers.register;
- function createController(verifier, message) {
+ function createController(verifier, message, required) {
controller = bid.Modules.CheckRegistration.create();
controller.start({
email: "registered@testuser.com",
verifier: verifier,
- verificationMessage: message
+ verificationMessage: message,
+ required: required
});
}
@@ -76,7 +77,7 @@
});
});
- asyncTest("back - raise cancel_state", function() {
+ asyncTest("back for normal account creation/email addition - raise cancel_state", function() {
createController("waitForUserValidation", "user_verified");
controller.startCheck(function() {
register("cancel_state", function() {
@@ -87,14 +88,14 @@
});
});
- asyncTest("cancel - raise cancel", function() {
- createController("waitForUserValidation", "user_verified");
+ asyncTest("back for required email - raise cancel", function() {
+ createController("waitForUserValidation", "user_verified", true);
controller.startCheck(function() {
register("cancel", function() {
ok(true, "cancel is triggered");
start();
});
- controller.cancel();
+ controller.back();
});
});
Oops, something went wrong.

0 comments on commit 350636a

Please sign in to comment.