Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding more error messages.
Going through all the user api and making sure all async functions have onFailure callbacks.

Adding tests for the user api to make sure that xhr failures cascade up.

Adding more messages to error-messages.

making sure the controllers are displaying error messages appropriately.

issue mozilla#448
  • Loading branch information
Shane Tomlinson committed Oct 24, 2011
1 parent b0ce93d commit 3c600bf
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 44 deletions.
15 changes: 9 additions & 6 deletions browserid/static/dialog/controllers/dialog_controller.js
Expand Up @@ -42,7 +42,9 @@
(function() {
"use strict";

var user = BrowserID.User;
var bid = BrowserID,
user = bid.User,
errors = bid.Errors;

PageController.extend("Dialog", {}, {
init: function(el) {
Expand Down Expand Up @@ -182,7 +184,8 @@
doEmailConfirmed: function() {
var self=this;
// yay! now we need to produce an assertion.
user.getAssertion(this.confirmEmail, self.doAssertionGenerated.bind(self));
user.getAssertion(this.confirmEmail, self.doAssertionGenerated.bind(self),
self.getErrorDialog(errors.getAssertion));
},

doAssertionGenerated: function(assertion) {
Expand All @@ -195,16 +198,16 @@
},

doNotMe: function() {
user.logoutUser(this.doAuthenticate.bind(this));
var self=this;
user.logoutUser(self.doAuthenticate.bind(self), self.getErrorDialog(errors.logoutUser));
},

syncEmails: function() {
var self = this;
user.syncEmails(self.doPickEmail.bind(self),
self.getErrorDialog(BrowserID.Errors.signIn));
self.getErrorDialog(errors.signIn));
},


doCheckAuth: function() {
var self=this;
user.checkAuthenticationAndSync(function onSuccess() {},
Expand All @@ -215,7 +218,7 @@
self.doAuthenticate();
}
},
self.getErrorDialog(BrowserID.Errors.checkAuthentication));
self.getErrorDialog(errors.checkAuthentication));
}

});
Expand Down
5 changes: 3 additions & 2 deletions browserid/static/dialog/controllers/pickemail_controller.js
Expand Up @@ -40,6 +40,7 @@
var ANIMATION_TIME = 250,
bid = BrowserID,
user = bid.User,
errors = bid.Errors,
body = $("body"),
animationComplete = body.innerWidth() < 640,
assertion;
Expand Down Expand Up @@ -110,7 +111,7 @@
user.getAssertion(email, function(assert) {
assertion = assert || null;
tryClose.call(self);
});
}, self.getErrorDialog(errors.getAssertion));
}

function startAnimation() {
Expand Down Expand Up @@ -168,7 +169,7 @@
bid.Tooltip.showTooltip("#could_not_add");
});
}
});
}, self.getErrorDialog(errors.isEmailRegistered));
}


Expand Down
18 changes: 15 additions & 3 deletions browserid/static/dialog/resources/error-messages.js
Expand Up @@ -54,16 +54,28 @@ BrowserID.Errors = (function(){
message: "There was a technical problem while trying to log you in. Yucky!"
},

createUser: {
type: "serverError",
title: "Error Creating Account",
message: "There was a technical problem while trying to create your account. Yucky!"
},

getAssertion: {
type: "serverError",
title: "Error Getting Assertion",
message: "There was a technical problem while trying to authenticate you. Yucky!"
},

isEmailRegistered: {
type: "serverError",
title: "Error Checking Email Address",
message: "There was a technical problem while trying to check that email address. Yucky!"
},

createUser: {
logoutUser: {
type: "serverError",
title: "Error Creating Account",
message: "There was a technical problem while trying to create your account. Yucky!"
title: "Logout Failed",
message: "An error was encountered while signing you out. Yucky!"
},

registration: {
Expand Down
10 changes: 5 additions & 5 deletions browserid/static/dialog/resources/user.js
Expand Up @@ -118,7 +118,7 @@ BrowserID.User = (function() {
else if (onFailure) {
onFailure(status);
}
});
}, onFailure);
};

poll();
Expand Down Expand Up @@ -285,7 +285,7 @@ BrowserID.User = (function() {
if (onSuccess) {
onSuccess();
}
});
}, onFailure);

},

Expand All @@ -301,7 +301,7 @@ BrowserID.User = (function() {
if (onSuccess) {
onSuccess();
}
});
}, onFailure);
},

/**
Expand Down Expand Up @@ -356,7 +356,7 @@ BrowserID.User = (function() {
}

addNextEmail();
});
}, onFailure);
},

/**
Expand Down Expand Up @@ -533,7 +533,7 @@ BrowserID.User = (function() {
if (onSuccess) {
onSuccess(assertion);
}
});
}, onFailure);
}

if (storedID) {
Expand Down

0 comments on commit 3c600bf

Please sign in to comment.