diff --git a/browserid/static/dialog/dialog/controllers/dialog_controller.js b/browserid/static/dialog/dialog/controllers/dialog_controller.js index 46cd4be1826b774650a9f8b853aaac92ac624b5a..2e5eda146180f0d5ffebeee4619487b968c281b4 100644 --- a/browserid/static/dialog/dialog/controllers/dialog_controller.js +++ b/browserid/static/dialog/dialog/controllers/dialog_controller.js @@ -10,9 +10,17 @@ $.Controller("Dialog", {}, { this.element.show(); // keep track of where we are and what we do on success and error - this.state = null; this.onsuccess = null; this.onerror = null; + + }, + + // this is not working yet + "#body keypress": function(e){ + if(e.which == 13) { + $('.submit').click(); + e.preventDefault(); + } }, "#signin click": function(event) { @@ -98,23 +106,68 @@ $.Controller("Dialog", {}, { self.doAuthenticate(); }); }, + + "#create click": function(event) { + this.doCreate(); + }, + + "#forgotpassword click": function(event) { + this.doForgotPassword(); + }, "#cancel click": function(event) { this.onerror("canceled"); }, + "#back click": function(event) { + this.doStart(); + }, + "#continue_button click": function(event) { this.doSignIn(); }, - getVerifiedEmail: function(remoteOrigin, onsuccess, onerror) { - // check to see if there's any pubkeys stored in the browser - var haveIDs = _.keys(getEmails()).length > 0; + "#create_continue click": function(event) { + // now we need to actually try to stage the creation of this account. + var email = this.find("#email_input").val(); + var pass = this.find("#password_input").val(); + var keypair = CryptoStubs.genKeyPair(); + + this.doWait( + "One Moment Please...", + "We're creating your account, this should only take a couple seconds"); + var self = this; + $.ajax({ + url: '/wsapi/stage_user?email=' + encodeURIComponent(email) + + '&pass=' + encodeURIComponent(pass) + + '&pubkey=' + encodeURIComponent(keypair.pub) + + '&site=' + encodeURIComponent(this.remoteOrigin.replace(/^(http|https):\/\//, '')), + success: function() { + // account successfully staged, now wait for email confirmation + self.doConfirmEmail(email, keypair); + }, + error: function() { + runErrorDialog( + "serverError", + "Error Creating Account!", + "There was a technical problem while trying to create your account. Yucky."); + } + }); + }, + + getVerifiedEmail: function(remoteOrigin, onsuccess, onerror) { this.onsuccess = onsuccess; this.onerror = onerror; this.remoteOrigin = remoteOrigin; + this.doStart(); + }, + + doStart: function() { + // check to see if there's any pubkeys stored in the browser + var haveIDs = _.keys(getEmails()).length > 0; + var self = this; // wherever shall we start? if (haveIDs) { @@ -125,21 +178,32 @@ $.Controller("Dialog", {}, { self.syncIdentities(); }, function() { self.doAuthenticate(); - }, onsuccess, onerror); + }); } }, doSignIn: function() { - this.state = "signin"; $('#dialog').html("views/signin.ejs", {sitename: this.remoteOrigin, identities: getEmails()}); $('#bottom-bar').html("views/bottom-pickemail.ejs", {}); + + // select the first option + this.find('input:first').attr('checked', true); }, doAuthenticate: function() { - this.state = "authenticate"; $('#dialog').html("views/authenticate.ejs", {sitename: this.remoteOrigin}); $('#bottom-bar').html("views/bottom-signin.ejs", {}); }, + + doCreate: function() { + $('#dialog').html("views/create.ejs", {}); + $('#bottom-bar').html("views/bottom-continue.ejs", {}); + }, + + doForgotPassword: function() { + $('#dialog').html("views/forgotpassword.ejs", {}); + $('#bottom-bar').html("views/bottom-continue.ejs", {}); + }, doWait: function(title, message) { $('#dialog').html("views/wait.ejs", {title: title, message: message}); @@ -152,7 +216,7 @@ $.Controller("Dialog", {}, { doConfirmEmail: function(email, keypair) { $('#dialog').html("views/confirmemail.ejs", {email:email}); - $('#bottom-bar').html(""); + $('#bottom-bar').html("views/bottom-confirmemail.ejs", {}); var self = this; diff --git a/browserid/static/dialog/dialog/views/authenticate.ejs b/browserid/static/dialog/dialog/views/authenticate.ejs index 9d0fc503c2ea9e070ec28306d9ff6d4ca657289c..7fe1a8cbd4c19e75e29898769c2bcc17d7958c95 100644 --- a/browserid/static/dialog/dialog/views/authenticate.ejs +++ b/browserid/static/dialog/dialog/views/authenticate.ejs @@ -7,12 +7,12 @@ <div class="input"> <div class="label"> Password </div> <div class="input"> <input type="password" id="password_input"></input></div> - <div class="note"> <a href="#">I forgot my password</a> </div> + <div class="note"> <a href="#" id="forgotpassword">I forgot my password</a> </div> </div> <div class="attention_lame" id="nosuchaccount" style="display:none;"> No such account exists with that email and/or password </div> <div class="actions"> - <div class="action"><a href="#">Don't have a BrowserID yet?</a></div> + <div class="action"><a href="#" id="create">Don't have a BrowserID yet?</a></div> </div> </div> diff --git a/browserid/static/dialog/dialog/views/bottom-addemail.ejs b/browserid/static/dialog/dialog/views/bottom-addemail.ejs index dd6467895c3d272720c6b43597677e2a13947bfb..06c26d8a611151908f2a3d04167048e044da249b 100644 --- a/browserid/static/dialog/dialog/views/bottom-addemail.ejs +++ b/browserid/static/dialog/dialog/views/bottom-addemail.ejs @@ -1,3 +1,3 @@ <button id="back">Go Back</button> - <button id="addemail_button" class="righty action">Add Email</button> + <button id="addemail_button" class="righty action submit">Add Email</button> <button id="cancel" class="righty">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/bottom-confirmemail.ejs b/browserid/static/dialog/dialog/views/bottom-confirmemail.ejs index 0c7bfbc71c30c65a594cbda42f3d1a112e854337..a12dda8935ab5ea8c63fcfc35cb3c6ab1517143a 100644 --- a/browserid/static/dialog/dialog/views/bottom-confirmemail.ejs +++ b/browserid/static/dialog/dialog/views/bottom-confirmemail.ejs @@ -1,2 +1,2 @@ -<button class="righty action" id="continue_button">Continue</button> +<button class="righty action submit" id="continue_button">Continue</button> <button class="righty" id="cancel">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/bottom-continue.ejs b/browserid/static/dialog/dialog/views/bottom-continue.ejs new file mode 100644 index 0000000000000000000000000000000000000000..53d61073047ae36a5e2658c8c0269ff94970fb2e --- /dev/null +++ b/browserid/static/dialog/dialog/views/bottom-continue.ejs @@ -0,0 +1,3 @@ + <button id="back">Go Back</button> + <button id="create_continue" class="righty action submit">Continue</button> + <button id="cancel" class="righty">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/bottom-pickemail.ejs b/browserid/static/dialog/dialog/views/bottom-pickemail.ejs index 9cfb13181e00a342370a8ea824325b5892c27eb9..debe989ff1c3cb8865cb52cead510c6f58a5a59e 100644 --- a/browserid/static/dialog/dialog/views/bottom-pickemail.ejs +++ b/browserid/static/dialog/dialog/views/bottom-pickemail.ejs @@ -1,2 +1,2 @@ - <button id="pickemail" class="righty action">Sign In</button> + <button id="pickemail" class="righty action submit">Sign In</button> <button id="cancel" class="righty">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/bottom-signin.ejs b/browserid/static/dialog/dialog/views/bottom-signin.ejs index 1c6138649483bdb258f48dfaced55222240f5d1b..f069d5033a3d9daf7826300cd74efcdbcb4d81c3 100644 --- a/browserid/static/dialog/dialog/views/bottom-signin.ejs +++ b/browserid/static/dialog/dialog/views/bottom-signin.ejs @@ -1,2 +1,2 @@ - <button id="signin" class="righty action">Sign In</button> + <button id="signin" class="righty action submit">Sign In</button> <button id="cancel" class="righty">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/bottom.ejs b/browserid/static/dialog/dialog/views/bottom.ejs index e42e3b19d882fbb3d83e7fe32dd30a483f4536dd..5c9aca7b789465b1d9c5fc0b85e8cb90a646237c 100644 --- a/browserid/static/dialog/dialog/views/bottom.ejs +++ b/browserid/static/dialog/dialog/views/bottom.ejs @@ -1,3 +1,3 @@ <button id="back">Go Back</button> - <button id="submit" class="righty action">Sign In</button> + <button id="submit" class="righty action submit">Sign In</button> <button id="cancel" class="righty">Cancel</button> diff --git a/browserid/static/dialog/dialog/views/create.ejs b/browserid/static/dialog/dialog/views/create.ejs new file mode 100644 index 0000000000000000000000000000000000000000..7df17fb0a1cc7d5e00a69c8a49903cd4af17ac74 --- /dev/null +++ b/browserid/static/dialog/dialog/views/create.ejs @@ -0,0 +1,20 @@ + <div class="content"> + <div class="summary">BrowserID makes logging in <b>safer and easier</b>. To begin, please provide an email address and pick a password:</div> + <div class="input"> + <div class="label"> Email </div> + <div class="input"> <input id="email_input" type="text"></input></div> + <div class="note"></div> + </div> + <div class="input"> + <div class="label"> Password </div> + <div class="input"> <input id="password_input" type="password"></input></div> + </div> + <div class="input"> + <div class="label"> Verify </div> + <div class="input"> <input id="password_verify_input" type="password"></input></div> + <div class="note"><span class="bad">Enter a password</span></div> + </div> + <div class="attention_lame" style="display:none;"> + <span id="in_use_email">Email</span> in use, If this email is yours you can <a href="#">sign in</a> with it? + </div> + </div> diff --git a/browserid/static/dialog/dialog/views/forgotpassword.ejs b/browserid/static/dialog/dialog/views/forgotpassword.ejs new file mode 100644 index 0000000000000000000000000000000000000000..eb09e3eca681f9a1250876ae3280e7d45c73d33a --- /dev/null +++ b/browserid/static/dialog/dialog/views/forgotpassword.ejs @@ -0,0 +1,20 @@ + <div class="content"> + <div class="summary"><b>Forgot your password?</b> No problem! Enter your email address, pick a new password, and we'll get you set up again!</div> + <div class="input"> + <div class="label"> Email </div> + <div class="input"> <input type="text" id="email_input"></input></div> + <div class="note"></div> + </div> + <div class="input"> + <div class="label"> Password </div> + <div class="input"> <input type="password" id="password_input"></input></div> + </div> + <div class="input"> + <div class="label"> Verify </div> + <div class="input"> <input type="password" id="password_verify_input"></input></div> + <div class="note"><span class="bad">Enter a password</span></div> + </div> + <div class="attention_lame" style="display:none;"> + <span id="in_use_email">Email</span> in use, If this email is yours you can <a href="#" id="signin_hint">sign in</a> with it? + </div> + </div> diff --git a/browserid/static/include.js b/browserid/static/include.js index 25b3ddf61cb1f7d60fd018aaf3832a2a81f4ca5a..cfbd04697339bb358c7bdb2d01bdb358cc400a60 100644 --- a/browserid/static/include.js +++ b/browserid/static/include.js @@ -540,7 +540,7 @@ if (!navigator.id.getVerifiedEmail || navigator.id._getVerifiedEmailIsShimmed) return window.open( ipServer + "/dialog/dialog/dialog.html", "_mozid_signin", //ipServer + "/sign_in", "_mozid_signin", - "menubar=0,location=0,resizable=0,scrollbars=0,status=0,dialog=1,width=820,height=850"); + "menubar=0,location=0,resizable=0,scrollbars=0,status=0,dialog=1,width=520,height=350"); } navigator.id.getVerifiedEmail = function(callback) {