diff --git a/browserid/static/dialog/controllers/addemail_controller.js b/browserid/static/dialog/controllers/addemail_controller.js index 83b88e7cf0c1a2ff25d8f7e44b07e133ba687a15..5d59c380ece2ff285ab6456af557006048ca3bf4 100644 --- a/browserid/static/dialog/controllers/addemail_controller.js +++ b/browserid/static/dialog/controllers/addemail_controller.js @@ -43,7 +43,7 @@ bodyTemplate: "addemail.ejs", bodyVars: { sitename: BrowserIDNetwork.origin, - identities: BrowserIDIdentities.getStoredIdentities() + identities: BrowserIDIdentities.getStoredEmailKeypairs() }, footerTemplate: "bottom-addemail.ejs", footerVars: {} @@ -66,7 +66,7 @@ this.doWait(BrowserIDWait.addEmail); var self = this; - BrowserIDIdentities.addIdentity(email, function(keypair) { + BrowserIDIdentities.addEmail(email, function(keypair) { // email successfully staged, now wait for email confirmation self.close("addemail:complete", { email: email, diff --git a/browserid/static/dialog/controllers/authenticate_controller.js b/browserid/static/dialog/controllers/authenticate_controller.js index a7733d1b53f1c75b3bb1dfd38cc39a7006e83cb5..0ac885a44eb7b6e94e05ba03cb905b5b6d2c978e 100644 --- a/browserid/static/dialog/controllers/authenticate_controller.js +++ b/browserid/static/dialog/controllers/authenticate_controller.js @@ -88,7 +88,7 @@ var self = this, email = $("#email").val(); - identities.createIdentity(email, function(keypair) { + identities.createUser(email, function(keypair) { self.close("createaccount:staged", { email: email, keypair: keypair diff --git a/browserid/static/dialog/controllers/createaccount_controller.js b/browserid/static/dialog/controllers/createaccount_controller.js deleted file mode 100644 index b2c8a94337894aaaf021d202e634464f5494c7a4..0000000000000000000000000000000000000000 --- a/browserid/static/dialog/controllers/createaccount_controller.js +++ /dev/null @@ -1,164 +0,0 @@ -/*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global BrowserIDIdentities: true, BrowserIDNetwork: true, BrowserIDWait:true, BrowserIDErrors: true, PageController: true */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla BrowserID. - * - * The Initial Developer of the Original Code is Mozilla. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -(function() { - "use strict"; - - PageController.extend("Createaccount", {}, { - init: function() { - this._super({ - bodyTemplate: "create.ejs", - bodyVars: {}, - footerTemplate: "bottom-continue.ejs", - footerVars: {} - }); - - $('#create_continue').addClass('disabled'); - - // watch input dialogs - this.setupWatchers(); - }, - - validate: function() { - if ($('#create_continue').hasClass('disabled')) - return false; - return true; - }, - - submit: function() { - // now we need to actually try to stage the creation of this account. - var email = this.find("#email").val(); - var pass = this.find("#password").val(); - - this.doWait(BrowserIDWait.createAccount); - - var self = this; - BrowserIDIdentities.stageIdentity(email, pass, function(keypair) { - self.close("createaccount:created", { - email: email, - keypair: keypair - }); - }, self.getErrorDialog(BrowserIDErrors.createAccount)); - }, - - setupWatchers: function() { - var checkedEmails = {}; - var emailCheckState = null; - var nextEmailToCheck = null; - var self = this; - - function checkInput() { - // check the email address - var email = self.find("#email").val(); - - if (typeof email === 'string' && email.length) { - var valid = checkedEmails[email]; - if (typeof valid === 'string') { - // oh noes. we tried to check this email, but it failed. let's just not tell the - // user anything, cause this is a non-critical issue - } else if (typeof valid === 'boolean') { - if (valid) { - self.find("#email_note").show(); - self.find("#emailinuse_message").hide(); - } else { - $("#emailinuse_message").fadeIn(300); - self.find("#email_note").hide(); - $("#in_use_email").text(email); - } - } else { - // this is an email that needs to be checked! - if (emailCheckState !== 'querying') { - if (emailCheckState) { - window.clearTimeout(emailCheckState); - } - emailCheckState = setTimeout(function() { - emailCheckState = 'querying'; - var checkingNow = nextEmailToCheck; - // bounce off the server and enter the 'querying' state - BrowserIDNetwork.haveEmail(checkingNow, function(success) { - checkedEmails[checkingNow] = success; - emailCheckState = undefined; - checkInput(); - },function() { - // some kind of error was encountered. This is non-critical, we'll simply ignore it - // and mark this email check as failed. - checkedEmails[checkingNow] = "server failed"; - emailCheckState = undefined; - checkInput(); - } - ); - }, 700); - } else { - // FIXME: not sure when this comes up, not refactored - // $("#create_dialog div.note:eq(0)").html($('<span class="warning"/>').text("Checking address")); - } - } - nextEmailToCheck = email; - } - - // next let's check the password entry - var pass = $("#password").val(); - var match = pass === $("#password_verify_input").val(); - self.find('.passwordnote').hide(); - $('#create_continue').addClass('disabled'); - if (!match) { - self.find('#passwords_different').show(); - } else { - if (!pass) { - self.find('#enter_a_password').show(); - } else if (pass.length < 8) { - self.find('#password_too_short').show(); - } else if (pass.length > 80) { - self.find('#password_too_long').show(); - } else { - self.find('#password_ok').show(); - $('#create_continue').removeClass('disabled'); - } - } - } - - self.find("input").unbind('keyup').bind('keyup', checkInput); - // do a check at load time, in case the user is using the back button (enables the continue button!) - checkInput(); - }, - - "#suggest_signin click": function(event) { - this.close("createaccount:signin"); - } - - }); - -}()); diff --git a/browserid/static/dialog/controllers/dialog_controller.js b/browserid/static/dialog/controllers/dialog_controller.js index 749d3baa1c0a239227f60761d05d01e41f0f0488..37e00921e21eba27a764b91fcf2458ba9e0e101e 100644 --- a/browserid/static/dialog/controllers/dialog_controller.js +++ b/browserid/static/dialog/controllers/dialog_controller.js @@ -85,7 +85,7 @@ PageController.extend("Dialog", {}, { }); */ hub.subscribe("authenticate:authenticated", function() { - self.syncIdentities(); + self.syncEmailKeypairs(); }); /* hub.subscribe("authenticate:createuser", function() { @@ -190,7 +190,7 @@ PageController.extend("Dialog", {}, { doEmailSelected: function(email) { var self=this; // yay! now we need to produce an assertion. - BrowserIDIdentities.getIdentityAssertion(email, function(assertion) { + BrowserIDIdentities.getAssertion(email, function(assertion) { // 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. @@ -203,9 +203,9 @@ PageController.extend("Dialog", {}, { BrowserIDIdentities.logoutUser(this.doAuthenticate.bind(this)); }, - syncIdentities: function() { + syncEmailKeypairs: function() { var self = this; - BrowserIDIdentities.syncIdentities(self.doSignIn.bind(self), + BrowserIDIdentities.syncEmailKeypairs(self.doSignIn.bind(self), self.getErrorDialog(BrowserIDErrors.signIn)); }, diff --git a/browserid/static/dialog/controllers/forgotpassword_controller.js b/browserid/static/dialog/controllers/forgotpassword_controller.js index 8f0a12c00e0e3968fe6c685ae76e17a7eceabefb..1be33dda11c1d68ecd8ac20431b60bc3da6fe2b9 100644 --- a/browserid/static/dialog/controllers/forgotpassword_controller.js +++ b/browserid/static/dialog/controllers/forgotpassword_controller.js @@ -1,5 +1,5 @@ /*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global BrowserIDIdentities: true, BrowserIDWait:true, BrowserIDErrors: true, PageController: true */ +/*global BrowserIDWait:true, BrowserIDErrors: true, PageController: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * diff --git a/browserid/static/dialog/controllers/pickemail_controller.js b/browserid/static/dialog/controllers/pickemail_controller.js index e3a94b8d19496ff69f7256c1b98a19f1655fbd69..3a287c4ff8f21724c916ba8151ed054094bd2297 100644 --- a/browserid/static/dialog/controllers/pickemail_controller.js +++ b/browserid/static/dialog/controllers/pickemail_controller.js @@ -44,7 +44,7 @@ bodyVars: { sitename: BrowserIDNetwork.origin, siteicon: '/i/times.gif', - identities: BrowserIDIdentities.getStoredIdentities(), + identities: BrowserIDIdentities.getStoredEmailKeypairs(), } }); // select the first option diff --git a/browserid/static/dialog/dialog.js b/browserid/static/dialog/dialog.js index efd4590247d3a828b2784efd5bc88c2912196394..6e2335ed9305beeae12c492630e39a5acb7f6cc0 100644 --- a/browserid/static/dialog/dialog.js +++ b/browserid/static/dialog/dialog.js @@ -63,7 +63,6 @@ steal.plugins( .controllers('page', 'dialog', 'authenticate', - 'createaccount', 'checkregistration', 'setpassword', 'forgotpassword', @@ -80,7 +79,6 @@ steal.plugins( 'bottom-signin.ejs', 'bottom.ejs', 'confirmemail.ejs', - 'create.ejs', 'forgotpassword.ejs', 'signin.ejs', 'wait.ejs' diff --git a/browserid/static/dialog/resources/browserid-identities.js b/browserid/static/dialog/resources/browserid-identities.js index a95376901b7c84154853d5122211ed6cf72acdad..00fec054447ed226dcfd21d53aedb58ff410323a 100644 --- a/browserid/static/dialog/resources/browserid-identities.js +++ b/browserid/static/dialog/resources/browserid-identities.js @@ -117,16 +117,70 @@ var BrowserIDIdentities = (function() { network = networkInterface; }, + /** + * Create a user account - this creates an user account that must be verified. + * @method createUser + * @param {string} email - Email address. + * @param {function} [onSuccess] - Called on successful completion. + * @param {function} [onFailure] - Called on error. + */ + createUser: function(email, onSuccess, onFailure) { + var self=this; + // FIXME: keysize + network.createUser(email, function() { + if (onSuccess) { + prepareDeps(); + var keypair = jwk.KeyPair.generate(vep.params.algorithm, 64); + self.stagedEmail = email; + self.stagedKeypair = keypair; + + onSuccess(keypair); + } + }, onFailure); + }, + + /** + * Cancel the current user's account. Remove last traces of their + * identity. + * @method cancelUser + * @param {function} [onSuccess] - Called whenever complete. + * @param {function} [onFailure] - called on failure. + */ + cancelUser: function(onSuccess, onFailure) { + network.cancelUser(function() { + setAuthenticationStatus(false); + if (onSuccess) { + onSuccess(); + } + }); + + }, + + /** + * Log the current user out. + * @method logoutUser + * @param {function} [onSuccess] - Called whenever complete. + * @param {function} [onFailure] - called on failure. + */ + logoutUser: function(onSuccess, onFailure) { + network.logout(function() { + setAuthenticationStatus(false); + if (onSuccess) { + onSuccess(); + } + }); + }, + /** * Sync local identities with browserid.org. Generally should not need to * be called. - * @method syncIdentities + * @method syncEmailKeypairs * @param {function} [onSuccess] - Called whenever complete. * @param {function} [onFailure] - Called on failure. */ - syncIdentities: function(onSuccess, onFailure) { + syncEmailKeypairs: function(onSuccess, onFailure) { cleanupIdentities(); - var issued_identities = Identities.getStoredIdentities(); + var issued_identities = Identities.getStoredEmailKeypairs(); // FIXME for certs @@ -165,45 +219,21 @@ var BrowserIDIdentities = (function() { var email = emails_to_add.shift(); - self.syncIdentity(email, addNextEmail, onFailure); + self.syncEmailKeypair(email, addNextEmail, onFailure); } addNextEmail(); }); }, - /** - * Stage an identity - this creates an identity that must be verified. - * Used when creating a new account or resetting the password of an - * existing account. - * @method createIdentity - * @param {string} email - Email address. - * @param {function} [onSuccess] - Called on successful completion. - * @param {function} [onFailure] - Called on error. - */ - createIdentity: function(email, onSuccess, onFailure) { - var self=this; - // FIXME: keysize - network.createUser(email, function() { - if (onSuccess) { - prepareDeps(); - var keypair = jwk.KeyPair.generate(vep.params.algorithm, 64); - self.stagedEmail = email; - self.stagedKeypair = keypair; - - onSuccess(keypair); - } - }, onFailure); - }, - /** * Signifies that an identity has been confirmed. - * @method confirmIdentity + * @method confirmEmail * @param {string} email - Email address. * @param {function} [onSuccess] - Called on successful completion. * @param {function} [onFailure] - Called on error. */ - confirmIdentity: function(email, onSuccess, onFailure) { + confirmEmail: function(email, onSuccess, onFailure) { var self = this; if (email === self.stagedEmail) { var keypair = self.stagedKeypair; @@ -212,8 +242,8 @@ var BrowserIDIdentities = (function() { self.stagedKeypair = null; // certify - Identities.certifyIdentity(email, keypair, function() { - self.syncIdentities(onSuccess, onFailure); + Identities.certifyEmailKeypair(email, keypair, function() { + self.syncEmailKeypairs(onSuccess, onFailure); }); } @@ -241,7 +271,7 @@ var BrowserIDIdentities = (function() { onSuccess(authenticated); } - self.syncIdentities(function() { + self.syncEmailKeypairs(function() { if (onComplete) { onComplete(authenticated); } @@ -274,7 +304,7 @@ var BrowserIDIdentities = (function() { onSuccess(authenticated); } - self.syncIdentities(function() { + self.syncEmailKeypairs(function() { if (onComplete) { onComplete(authenticated); } @@ -287,46 +317,16 @@ var BrowserIDIdentities = (function() { }, /** - * Certify an identity - */ - certifyIdentity: function(email, keypair, onSuccess, onFailure) { - network.certKey(email, keypair.publicKey, function(cert) { - Identities.persistIdentity(email, keypair, cert, function() { - if (onSuccess) { - onSuccess(); - } - }, onFailure); - }, onFailure); - }, - - /** - * Sync an identity with the server. Creates and stores locally and on the - * server a keypair for the given email address. - * @method syncIdentity - * @param {string} email - Email address. - * @param {string} [issuer] - Issuer of keypair. - * @param {function} [onSuccess] - Called on successful completion. - * @param {function} [onFailure] - Called on error. - */ - syncIdentity: function(email, onSuccess, onFailure) { - // FIXME use true key sizes - prepareDeps(); - //var keypair = jwk.KeyPair.generate(vep.params.algorithm, vep.params.keysize); - var keypair = jwk.KeyPair.generate(vep.params.algorithm, 64); - Identities.certifyIdentity(email, keypair, onSuccess, onFailure); - }, - - /** - * Add an identity to an already created account. Sends address and + * Add an email address to an already created account. Sends address and * keypair to the server, user then needs to verify account ownership. This * does not add the new email address/keypair to the local list of * valid identities. - * @method addIdentity + * @method addEmail * @param {string} email - Email address. * @param {function} [onSuccess] - Called on successful completion. * @param {function} [onFailure] - Called on error. */ - addIdentity: function(email, onSuccess, onFailure) { + addEmail: function(email, onSuccess, onFailure) { var self = this; prepareDeps(); var keypair = jwk.KeyPair.generate(vep.params.algorithm, 64); @@ -342,15 +342,61 @@ var BrowserIDIdentities = (function() { }, onFailure); }, + /** + * Remove an email address. + * @method removeEmail + * @param {string} email - Email address to remove. + * @param {function} [onSuccess] - Called when complete. + * @param {function} [onFailure] - Called on failure. + */ + removeEmail: function(email, onSuccess, onFailure) { + network.removeEmail(email, function() { + storage.removeEmail(email); + if (onSuccess) { + onSuccess(); + } + }, onFailure); + }, + + /** + * Sync an identity with the server. Creates and stores locally and on the + * server a keypair for the given email address. + * @method syncEmailKeypair + * @param {string} email - Email address. + * @param {string} [issuer] - Issuer of keypair. + * @param {function} [onSuccess] - Called on successful completion. + * @param {function} [onFailure] - Called on error. + */ + syncEmailKeypair: function(email, onSuccess, onFailure) { + // FIXME use true key sizes + prepareDeps(); + //var keypair = jwk.KeyPair.generate(vep.params.algorithm, vep.params.keysize); + var keypair = jwk.KeyPair.generate(vep.params.algorithm, 64); + Identities.certifyEmailKeypair(email, keypair, onSuccess, onFailure); + }, + + /** + * Certify an identity + */ + certifyEmailKeypair: function(email, keypair, onSuccess, onFailure) { + network.certKey(email, keypair.publicKey, function(cert) { + Identities.persistEmailKeypair(email, keypair, cert, function() { + if (onSuccess) { + onSuccess(); + } + }, onFailure); + }, onFailure); + }, + /** * Persist an address and key pair locally. - * @method persistIdentity + * @method persistEmailKeypair * @param {string} email - Email address to persist. * @param {object} keypair - Key pair to save * @param {function} [onSuccess] - Called on successful completion. * @param {function} [onFailure] - Called on error. */ - persistIdentity: function(email, keypair, cert, onSuccess, onFailure) { + persistEmailKeypair: function(email, keypair, cert, onSuccess, onFailure) { var new_email_obj= { created: new Date(), pub: keypair.publicKey.toSimpleObject(), @@ -365,31 +411,15 @@ var BrowserIDIdentities = (function() { } }, - /** - * Remove an email address. - * @method removeIdentity - * @param {string} email - Email address to remove. - * @param {function} [onSuccess] - Called when complete. - * @param {function} [onFailure] - Called on failure. - */ - removeIdentity: function(email, onSuccess, onFailure) { - network.removeEmail(email, function() { - storage.removeEmail(email); - if (onSuccess) { - onSuccess(); - } - }, onFailure); - }, - /** * Get an assertion for an identity - * @method getIdentityAssertion + * @method getAssertion * @param {string} email - Email to get assertion for. * @param {function} [onSuccess] - Called with assertion on success. * @param {function} [onFailure] - Called on failure. */ - getIdentityAssertion: function(email, onSuccess, onFailure) { - var storedID = Identities.getStoredIdentities()[email], + getAssertion: function(email, onSuccess, onFailure) { + var storedID = Identities.getStoredEmailKeypairs()[email], assertion; if (storedID) { @@ -408,55 +438,22 @@ var BrowserIDIdentities = (function() { /** * Get the list of identities stored locally. - * @method getStoredIdentities + * @method getStoredEmailKeypairs * @return {object} identities. */ - getStoredIdentities: function() { + getStoredEmailKeypairs: function() { return storage.getEmails(); }, /** * Clear the list of identities stored locally. - * @method clearStoredIdentities + * @method clearStoredEmailKeypairs */ - clearStoredIdentities: function() { + clearStoredEmailKeypairs: function() { storage.clearEmails(); }, - /** - * Cancel the current user's account. Remove last traces of their - * identity. - * @method cancelUser - * @param {function} [onSuccess] - Called whenever complete. - * @param {function} [onFailure] - called on failure. - */ - cancelUser: function(onSuccess, onFailure) { - network.cancelUser(function() { - setAuthenticationStatus(false); - if (onSuccess) { - onSuccess(); - } - }); - - }, - - /** - * Log the current user out. - * @method logoutUser - * @param {function} [onSuccess] - Called whenever complete. - * @param {function} [onFailure] - called on failure. - */ - logoutUser: function(onSuccess, onFailure) { - network.logout(function() { - setAuthenticationStatus(false); - if (onSuccess) { - onSuccess(); - } - }); - } - - }; return Identities; diff --git a/browserid/static/dialog/resources/browserid-network.js b/browserid/static/dialog/resources/browserid-network.js index 30d21274844a47e38f57a833d95e44586991c25e..dd08a228f72e7643de67b9a4edb873eeeba7d726 100644 --- a/browserid/static/dialog/resources/browserid-network.js +++ b/browserid/static/dialog/resources/browserid-network.js @@ -171,13 +171,21 @@ var BrowserIDNetwork = (function() { * @param {function} [onFailure] - Called on XHR failure. */ createUser: function(email, onSuccess, onFailure) { - // XXX fill this in + // XXX fill this in. if (onSuccess) { onSuccess(); } }, + /** + * Set the password of the current user. + * @method setPassword + * @param {string} password - password to set + * @param {function} [onSuccess] - Callback to call when complete. + * @param {function} [onFailure] - Called on XHR failure. + */ setPassword: function(password, onSuccess, onFailure) { + // XXX fill this in. if (onSuccess) { onSuccess(); } diff --git a/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js b/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js index bd1ed0f6b416bd03f2e569000261116438abeb54..705bccc80ff1d7e21e28002573d6966a99a25098 100644 --- a/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js +++ b/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js @@ -108,6 +108,14 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden } }, + createUser: function(email, onSuccess) { + onSuccess(); + }, + + setPassword: function(password, onSuccess) { + onSuccess(); + }, + cancelUser: function(onSuccess) { onSuccess(); }, @@ -136,14 +144,14 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }; } - test("getStoredIdentities", function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + test("getStoredEmailKeypairs", function() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal("object", typeof identities, "we have some identities"); }); - test("clearStoredIdentities", function() { - BrowserIDIdentities.clearStoredIdentities(); - var identities = BrowserIDIdentities.getStoredIdentities(); + test("clearStoredEmailKeypairs", function() { + BrowserIDIdentities.clearStoredEmailKeypairs(); + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); var count = 0; for(var key in identities) { if(identities.hasOwnProperty(key)) { @@ -154,47 +162,47 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden equal(0, count, "after clearing, there are no identities"); }); - test("stageIdentity", function() { - BrowserIDIdentities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { + test("createUser", function() { + BrowserIDIdentities.createUser("testuser@testuser.com", function(keypair) { equal("object", typeof keypair, "We have a key pair"); start(); - }, failure("stageIdentity failure")); + }, failure("createUser failure")); stop(); }); - test("confirmIdentity on staged identity", function() { - BrowserIDIdentities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { - BrowserIDIdentities.confirmIdentity("testuser@testuser.com", function() { + test("confirmEmail on staged identity", function() { + BrowserIDIdentities.createUser("testuser@testuser.com", function(keypair) { + BrowserIDIdentities.confirmEmail("testuser@testuser.com", function() { ok(true, "confirming staged identity"); start(); }); - }, failure("stageIdentity failure")); + }, failure("createUser failure")); stop(); }); - test("confirmIdentity on non staged identity", function() { - BrowserIDIdentities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { - BrowserIDIdentities.confirmIdentity("testuser2@testuser.com", function onSuccess() { + test("confirmEmail on non staged identity", function() { + BrowserIDIdentities.createUser("testuser@testuser.com", function(keypair) { + BrowserIDIdentities.confirmEmail("testuser2@testuser.com", function onSuccess() { ok(false, "confirming unstaged identity"); start(); }, function onFailure() { ok(true, "confirming unstaged identity should fail"); start(); }); - }, failure("stageIdentity failure")); + }, failure("createUser failure")); stop(); }); - test("confirmIdentity on previously confirmed identity", function() { - BrowserIDIdentities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { - BrowserIDIdentities.confirmIdentity("testuser@testuser.com", function() { - BrowserIDIdentities.confirmIdentity("testuser@testuser.com", function() { + test("confirmEmail on previously confirmed identity", function() { + BrowserIDIdentities.createUser("testuser@testuser.com", function(keypair) { + BrowserIDIdentities.confirmEmail("testuser@testuser.com", function() { + BrowserIDIdentities.confirmEmail("testuser@testuser.com", function() { ok(false, "confirming previously confirmed identity should fail"); start(); }, function onFailure() { @@ -202,7 +210,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden start(); }); }); - }, failure("stageIdentity failure")); + }, failure("createUser failure")); stop(); }); @@ -271,7 +279,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden BrowserIDIdentities.authenticateAndSync("testuser@testuser.com", "testuser", function() { }, function(authenticated) { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testuser@testuser.com" in identities, "authenticateAndSync syncs email addresses"); ok(authenticated, "we are authenticated") start(); @@ -289,7 +297,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden BrowserIDIdentities.authenticateAndSync("testuser@testuser.com", "testuser", function() { }, function(authenticated) { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal("testuser@testuser.com" in identities, false, "authenticateAndSync does not sync if authentication is invalid"); equal(authenticated, false, "not authenticated"); start(); @@ -300,45 +308,45 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden - test("addIdentity", function() { - BrowserIDIdentities.addIdentity("testemail@testemail.com", function(keypair) { + test("addEmail", function() { + BrowserIDIdentities.addEmail("testemail@testemail.com", function(keypair) { equal("object", typeof keypair, "we have a keypair"); - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal(false, "testemail@testemail.com" in identities, "Our new email is not added until confirmation."); start(); - }, failure("addIdentity failure")); + }, failure("addEmail failure")); stop(); }); - test("syncIdentity with successful sync", function() { + test("syncEmailKeypair with successful sync", function() { BrowserIDStorage.clearEmails(); syncValid = true; - BrowserIDIdentities.syncIdentity("testemail@testemail.com", function(keypair) { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypair("testemail@testemail.com", function(keypair) { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testemail@testemail.com" in identities, "Valid email is synced"); start(); - }, failure("syncIdentity failure")); + }, failure("syncEmailKeypair failure")); stop(); }); - test("syncIdentity with invalid sync", function() { + test("syncEmailKeypair with invalid sync", function() { BrowserIDStorage.clearEmails(); syncValid = false; - BrowserIDIdentities.syncIdentity("testemail@testemail.com", function(keypair) { + BrowserIDIdentities.syncEmailKeypair("testemail@testemail.com", function(keypair) { ok(false, "sync was invalid, this should have failed"); start(); }, function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal("testemail@testemail.com" in identities, false, "Invalid email is not synced"); start(); @@ -349,10 +357,10 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden - test("persistIdentity", function() { + test("persistEmailKeypair", function() { var user_kp = jwk.KeyPair.generate("RS",64); - BrowserIDIdentities.persistIdentity("testemail2@testemail.com", user_kp, undefined, function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.persistEmailKeypair("testemail2@testemail.com", user_kp, undefined, function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testemail2@testemail.com" in identities, "Our new email is added"); start(); }); @@ -362,40 +370,40 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden - test("removeIdentity that is added", function() { + test("removeEmail that is added", function() { BrowserIDStorage.addEmail("testemail@testemail.com", {pub: "pub", priv: "priv"}); - BrowserIDIdentities.removeIdentity("testemail@testemail.com", function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.removeEmail("testemail@testemail.com", function() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal(false, "testemail@testemail.com" in identities, "Our new email is removed"); start(); - }, failure("removeIdentity failure")); + }, failure("removeEmail failure")); stop(); }); - test("removeIdentity that is not added", function() { + test("removeEmail that is not added", function() { BrowserIDStorage.clearEmails(); - BrowserIDIdentities.removeIdentity("testemail@testemail.com", function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.removeEmail("testemail@testemail.com", function() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); equal(false, "testemail@testemail.com" in identities, "Our new email is removed"); start(); - }, failure("removeIdentity failure")); + }, failure("removeEmail failure")); stop(); }); - test("syncIdentities with no pre-loaded identities and no identities to add", function() { + test("syncEmailKeypairs with no pre-loaded identities and no identities to add", function() { BrowserIDStorage.clearEmails(); userEmails = {}; - BrowserIDIdentities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypairs(function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok(true, "we have synced identities"); equal(_.size(identities), 0, "there are no identities"); start(); @@ -404,12 +412,12 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden stop(); }); - test("syncIdentities with no pre-loaded identities and identities to add", function() { + test("syncEmailKeypairs with no pre-loaded identities and identities to add", function() { BrowserIDStorage.clearEmails(); userEmails = {"testuser@testuser.com": {}}; - BrowserIDIdentities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypairs(function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testuser@testuser.com" in identities, "Our new email is added"); equal(_.size(identities), 1, "there is one identity"); start(); @@ -418,12 +426,12 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden stop(); }); - test("syncIdentities with identities preloaded and none to add", function() { + test("syncEmailKeypairs with identities preloaded and none to add", function() { BrowserIDStorage.clearEmails(); userEmails = {"testuser@testuser.com": {}}; BrowserIDStorage.addEmail("testuser@testuser.com", {}); - BrowserIDIdentities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypairs(function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testuser@testuser.com" in identities, "Our new email is added"); equal(_.size(identities), 1, "there is one identity"); start(); @@ -433,14 +441,14 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); - test("syncIdentities with identities preloaded and one to add", function() { + test("syncEmailKeypairs with identities preloaded and one to add", function() { BrowserIDStorage.clearEmails(); BrowserIDStorage.addEmail("testuser@testuser.com", {pubkey: pubkey, cert: random_cert}); userEmails = {"testuser@testuser.com": {pubkey: pubkey, cert: random_cert}, "testuser2@testuser.com": {pubkey: pubkey, cert: random_cert}}; - BrowserIDIdentities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypairs(function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testuser@testuser.com" in identities, "Our old email address is still there"); ok("testuser2@testuser.com" in identities, "Our new email is added"); equal(_.size(identities), 2, "there are two identities"); @@ -451,14 +459,14 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); - test("syncIdentities with identities preloaded and one to remove", function() { + test("syncEmailKeypairs with identities preloaded and one to remove", function() { BrowserIDStorage.clearEmails(); BrowserIDStorage.addEmail("testuser@testuser.com", {pub: pubkey, cert: random_cert}); BrowserIDStorage.addEmail("testuser2@testuser.com", {pub: pubkey, cert: random_cert}); userEmails = {"testuser@testuser.com": { pub: pubkey, cert: random_cert}}; - BrowserIDIdentities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserIDIdentities.syncEmailKeypairs(function onSuccess() { + var identities = BrowserIDIdentities.getStoredEmailKeypairs(); ok("testuser@testuser.com" in identities, "Our old email address is still there"); equal("testuser2@testuser.com" in identities, false, "Our unknown email is removed"); equal(_.size(identities), 1, "there is one identity"); @@ -469,29 +477,29 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); - test("getIdentityAssertion with known email", function() { + test("getAssertion with known email", function() { BrowserIDStorage.clearEmails(); var keypair = jwk.KeyPair.generate("RS",64); - BrowserIDIdentities.certifyIdentity("testuser@testuser.com", keypair, function() { - BrowserIDIdentities.getIdentityAssertion("testuser@testuser.com", function onSuccess(assertion) { + BrowserIDIdentities.certifyEmailKeypair("testuser@testuser.com", keypair, function() { + BrowserIDIdentities.getAssertion("testuser@testuser.com", function onSuccess(assertion) { equal("string", typeof assertion, "we have an assertion!"); start(); }); - }, failure("getIdentityAssertion failure")); + }, failure("getAssertion failure")); stop(); }); - test("getIdentityAssertion with unknown email", function() { + test("getAssertion with unknown email", function() { BrowserIDStorage.clearEmails(); var keypair = jwk.KeyPair.generate("RS",64); - BrowserIDIdentities.certifyIdentity("testuser@testuser.com", keypair, function() { - BrowserIDIdentities.getIdentityAssertion("testuser2@testuser.com", function onSuccess(assertion) { + BrowserIDIdentities.certifyEmailKeypair("testuser@testuser.com", keypair, function() { + BrowserIDIdentities.getAssertion("testuser2@testuser.com", function onSuccess(assertion) { equal("undefined", typeof assertion, "email was unknown, we do not have an assertion"); start(); }); - }, failure("getIdentityAssertion failure")); + }, failure("getAssertion failure")); stop(); }); diff --git a/browserid/static/dialog/views/create.ejs b/browserid/static/dialog/views/create.ejs deleted file mode 100644 index 7bafe11ea5efb6aab72874fe01e6b27b1d28575b..0000000000000000000000000000000000000000 --- a/browserid/static/dialog/views/create.ejs +++ /dev/null @@ -1,26 +0,0 @@ - <div class="content"> - <div class="summary">BrowserID makes signing in <b>safer and easier</b>. To begin, please provide an email address and pick a password:</div> - <div class="formRow"> - <label for="email_input"> Email </label> - <input id="email_input" type="email" autocapitalize="off" autocorrect="off" required/> - <span class="note" id="email_input_note" style="display:none;"> - <span class="good">Not registered</span> - </span> - </div> - <div class="formRow"> - <label for="password_input"> Password </label> - <input id="password_input" type="password" pattern=".{5,}" required/> - </div> - <div class="formRow"> - <label for="password_verify_input"> Verify </label> - <input id="password_verify_input" type="password" pattern=".{5,}" required/> - <span class="note passwordnote" id="enter_a_password"><span class="bad">Enter a password</span></span> - <span class="note passwordnote" id="passwords_different" style="display:none;"><span class="bad">Passwords different</span></span> - <span class="note passwordnote" id="password_too_short" style="display:none;"><span class="bad">Password too short</span></span> - <span class="note passwordnote" id="password_too_long" style="display:none;"><span class="bad">Password too long</span></span> - <span class="note passwordnote" id="password_ok" style="display:none;"><span class="good">Password OK</span></span> - </div> - <div class="attention_lame" style="display:none;" id="emailinuse_message"> - <span id="in_use_email">Email</span> in use, If this email is yours you can <a href="#" id="suggest_signin" tabindex="0">sign in</a> with it? - </div> - </div> diff --git a/browserid/static/js/browserid.js b/browserid/static/js/browserid.js index 9211ff10fd8647b9526de4c501e013c4056abe78..cb97b6a189f08d7d9f1b39ff550397dd8dbfcf55 100644 --- a/browserid/static/js/browserid.js +++ b/browserid/static/js/browserid.js @@ -139,7 +139,7 @@ $(function() { function display_saved_ids() { var emails = {}; - BrowserIDIdentities.syncIdentities(function() { + BrowserIDIdentities.syncEmailKeypairs(function() { emails = getEmails(); if (_.isEmpty(emails)) { console.log(emails); @@ -203,7 +203,7 @@ function display_saved_ids() { event.preventDefault(); if (confirm("Remove " + email + " from your BrowserID?")) { - BrowserIDIdentities.removeIdentity(email, display_saved_ids); + BrowserIDIdentities.removeEmail(email, display_saved_ids); } } } @@ -234,7 +234,7 @@ function display_saved_ids() { }); $("#emailList").empty(); - var emails = BrowserIDIdentities.getStoredIdentities(); + var emails = BrowserIDIdentities.getStoredEmailKeypairs(); _(emails).each(function(data, e) { var block = $("<div>").addClass("emailblock"); var label = $("<div>").addClass("email").text(e); diff --git a/browserid/views/signup.ejs b/browserid/views/signup.ejs index b15236ca56d53e267d56e7e5e81067eb80107c85..789e7e90913c5cf012d016ce057bd24383358f67 100644 --- a/browserid/views/signup.ejs +++ b/browserid/views/signup.ejs @@ -48,7 +48,7 @@ return false; } - BrowserIDIdentities.stageIdentity(email, password, function onSuccess(authenticated) { + BrowserIDIdentities.createUser(email, function onSuccess(authenticated) { if (authenticated) { document.location = "/"; }