Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #107 from mozilla/close_dialog_call_failure_callback
Browse files Browse the repository at this point in the history
Call error callback when dialog closes before email selected.
  • Loading branch information
lloyd committed Aug 1, 2011
2 parents d5afea4 + c4fa810 commit 921069a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions browserid/static/dialog/controllers/dialog_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ $.Controller("Dialog", {}, {
var issuer = storedID.issuer;
var audience = this.remoteOrigin.replace(/^(http|https):\/\//, '');
var assertion = CryptoStubs.createAssertion(audience, email, privkey, issuer);
// Clear onerror before the call to onsuccess - the code to onsuccess
// calls window.close, which would trigger the onerror callback if we
// tried this afterwards.
this.onerror = null;
this.onsuccess(assertion);
},

Expand Down Expand Up @@ -219,6 +223,14 @@ $.Controller("Dialog", {}, {
this.onerror = onerror;
this.remoteOrigin = origin_url.replace(/^.*:\/\//, "");
this.doStart();
var me=this;
$(window).bind("unload", function() {
// In the success case, me.onerror will have been cleared before unload
// is triggered.
if (me.onerror) {
me.onerror("canceled");
}
});
},

doStart: function() {
Expand Down Expand Up @@ -550,3 +562,5 @@ $.Controller("Dialog", {}, {
}

});


0 comments on commit 921069a

Please sign in to comment.