Skip to content
Snippets Groups Projects
Commit de00a20b authored by Shane Tomlinson's avatar Shane Tomlinson Committed by Lloyd Hilaiel
Browse files

Make users who have not yet set their password by time they reach the landing...

Make users who have not yet set their password by time they reach the landing page set their password.

issue #1592
parent d625a4cd
No related branches found
No related tags found
No related merge requests found
...@@ -669,7 +669,7 @@ h1 { ...@@ -669,7 +669,7 @@ h1 {
margin-bottom: 10px; margin-bottom: 10px;
} }
.siteinfo, #congrats, .password_entry, .enter_password .hint, #unknown_secondary, #primary_verify, .verify_primary .submit { .siteinfo, #congrats, .password_entry, #verify_password, .enter_password .hint, #unknown_secondary, #primary_verify, .verify_primary .submit {
display: none; display: none;
} }
...@@ -677,7 +677,7 @@ h1 { ...@@ -677,7 +677,7 @@ h1 {
float: left; float: left;
} }
.enter_password .password_entry, .known_secondary .password_entry, .enter_password .password_entry, .enter_verify_password #verify_password, .known_secondary .password_entry,
.unknown_secondary #unknown_secondary, .verify_primary #verify_primary { .unknown_secondary #unknown_secondary, .verify_primary #verify_primary {
display: block; display: block;
} }
......
...@@ -17,6 +17,7 @@ BrowserID.verifySecondaryAddress = (function() { ...@@ -17,6 +17,7 @@ BrowserID.verifySecondaryAddress = (function() {
validation = bid.Validation, validation = bid.Validation,
token, token,
sc, sc,
needsPassword,
mustAuth, mustAuth,
verifyFunction; verifyFunction;
...@@ -36,7 +37,11 @@ BrowserID.verifySecondaryAddress = (function() { ...@@ -36,7 +37,11 @@ BrowserID.verifySecondaryAddress = (function() {
function submit(oncomplete) { function submit(oncomplete) {
var pass = dom.getInner("#password") || undefined, var pass = dom.getInner("#password") || undefined,
valid = !mustAuth || validation.password(pass); vpass = dom.getInner("#vpassword") || undefined,
valid = (!needsPassword ||
validation.passwordAndValidationPassword(pass, vpass))
&& (!mustAuth ||
validation.password(pass));
if (valid) { if (valid) {
user[verifyFunction](token, pass, function(info) { user[verifyFunction](token, pass, function(info) {
...@@ -56,13 +61,25 @@ BrowserID.verifySecondaryAddress = (function() { ...@@ -56,13 +61,25 @@ BrowserID.verifySecondaryAddress = (function() {
if(info) { if(info) {
showRegistrationInfo(info); showRegistrationInfo(info);
needsPassword = info.needs_password;
mustAuth = info.must_auth; mustAuth = info.must_auth;
if (mustAuth) { if (needsPassword) {
// This is a fix for legacy users who started the user creation
// process without setting their password in the dialog. If the user
// needs a password, they must set it now. Once all legacy users are
// verified or their links invalidated, this flow can be removed.
dom.addClass("body", "enter_password");
dom.addClass("body", "enter_verify_password");
complete(oncomplete, true);
}
else if (mustAuth) {
// These are users who have set their passwords inside of the dialog.
dom.addClass("body", "enter_password"); dom.addClass("body", "enter_password");
complete(oncomplete, true); complete(oncomplete, true);
} }
else { else {
// These are users who do not have to set their passwords at all.
submit(oncomplete); submit(oncomplete);
} }
} }
......
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
xhr.useResult("mustAuth"); xhr.useResult("mustAuth");
createController(config, function() { createController(config, function() {
xhr.useResult("valid"); xhr.useResult("valid");
testHasClass("body", "enter_password");
controller.submit(function(status) { controller.submit(function(status) {
equal(status, true, "correct status"); equal(status, true, "correct status");
testHasClass("body", "complete"); testHasClass("body", "complete");
...@@ -134,4 +135,88 @@ ...@@ -134,4 +135,88 @@
}); });
}); });
asyncTest("must set password, successful login", function() {
xhr.useResult("needsPassword");
createController(config, function() {
xhr.useResult("valid");
$("#password").val("password");
$("#vpassword").val("password");
testHasClass("body", "enter_password");
testHasClass("body", "enter_verify_password");
controller.submit(function(status) {
equal(status, true, "correct status");
testHasClass("body", "complete");
start();
});
});
});
asyncTest("must set password, too short a password", function() {
xhr.useResult("needsPassword");
createController(config, function() {
xhr.useResult("valid");
$("#password").val("pass");
$("#vpassword").val("pass");
controller.submit(function(status) {
equal(status, false, "correct status");
testHelpers.testTooltipVisible();
start();
});
});
});
asyncTest("must set password, too long a password", function() {
xhr.useResult("needsPassword");
createController(config, function() {
xhr.useResult("valid");
var pass = testHelpers.generateString(81);
$("#password").val(pass);
$("#vpassword").val(pass);
controller.submit(function(status) {
equal(status, false, "correct status");
testHelpers.testTooltipVisible();
start();
});
});
});
asyncTest("must set password, missing verification password", function() {
xhr.useResult("needsPassword");
createController(config, function() {
xhr.useResult("valid");
$("#password").val("password");
$("#vpassword").val("");
controller.submit(function(status) {
equal(status, false, "correct status");
testHelpers.testTooltipVisible();
start();
});
});
});
asyncTest("must set password, mismatched passwords", function() {
xhr.useResult("needsPassword");
createController(config, function() {
xhr.useResult("valid");
$("#password").val("password");
$("#vpassword").val("password1");
controller.submit(function(status) {
equal(status, false, "correct status");
testHelpers.testTooltipVisible();
start();
});
});
});
}()); }());
...@@ -34,6 +34,7 @@ BrowserID.Mocks.xhr = (function() { ...@@ -34,6 +34,7 @@ BrowserID.Mocks.xhr = (function() {
"get /wsapi/session_context contextAjaxError": undefined, "get /wsapi/session_context contextAjaxError": undefined,
"get /wsapi/email_for_token?token=token valid": { email: "testuser@testuser.com" }, "get /wsapi/email_for_token?token=token valid": { email: "testuser@testuser.com" },
"get /wsapi/email_for_token?token=token mustAuth": { email: "testuser@testuser.com", must_auth: true }, "get /wsapi/email_for_token?token=token mustAuth": { email: "testuser@testuser.com", must_auth: true },
"get /wsapi/email_for_token?token=token needsPassword": { email: "testuser@testuser.com", needs_password: true },
"get /wsapi/email_for_token?token=token invalid": { success: false }, "get /wsapi/email_for_token?token=token invalid": { success: false },
"post /wsapi/authenticate_user valid": { success: true, userid: 1 }, "post /wsapi/authenticate_user valid": { success: true, userid: 1 },
"post /wsapi/authenticate_user invalid": { success: false }, "post /wsapi/authenticate_user invalid": { success: false },
......
...@@ -31,6 +31,20 @@ ...@@ -31,6 +31,20 @@
<%= gettext('Password must be between 8 and 80 characters long.') %> <%= gettext('Password must be between 8 and 80 characters long.') %>
</div> </div>
</li> </li>
<li class="password_entry" id="verify_password">
<label class="serif" for="vpassword"><%= gettext('Verify Password') %></label>
<input class="sans" id="vpassword" placeholder="<%= gettext('Repeat Password') %>" type="password" maxlength="80">
<div id="vpassword_required" class="tooltip" for="vpassword">
<%= gettext('Verification password is required.') %>
</div>
<div class="tooltip" id="passwords_no_match" for="vpassword">
<%= gettext ('Passwords do not match.') %>
</div>
</li>
</ul> </ul>
<div class="submit cf password_entry"> <div class="submit cf password_entry">
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<label class="serif" for="email"><%= gettext('Email Address') %></label> <label class="serif" for="email"><%= gettext('Email Address') %></label>
<input class="youraddress sans" id="email" placeholder="<%= gettext('Your Email') %>" type="email" value="" disabled="disabled" maxlength="254" /> <input class="youraddress sans" id="email" placeholder="<%= gettext('Your Email') %>" type="email" value="" disabled="disabled" maxlength="254" />
</li> </li>
<li class="password_entry"> <li class="password_entry">
<label class="serif" for="password"><%= gettext('Password') %></label> <label class="serif" for="password"><%= gettext('Password') %></label>
<input class="sans" id="password" placeholder="<%= gettext('Your Password') %>" type="password" autofocus maxlength=80 /> <input class="sans" id="password" placeholder="<%= gettext('Your Password') %>" type="password" autofocus maxlength=80 />
...@@ -30,6 +31,20 @@ ...@@ -30,6 +31,20 @@
<%= gettext('Password must be between 8 and 80 characters long.') %> <%= gettext('Password must be between 8 and 80 characters long.') %>
</div> </div>
</li> </li>
<li class="password_entry" id="verify_password">
<label class="serif" for="vpassword"><%= gettext('Verify Password') %></label>
<input class="sans" id="vpassword" placeholder="<%= gettext('Repeat Password') %>" type="password" maxlength="80">
<div id="vpassword_required" class="tooltip" for="vpassword">
<%= gettext('Verification password is required.') %>
</div>
<div class="tooltip" id="passwords_no_match" for="vpassword">
<%= gettext ('Passwords do not match.') %>
</div>
</li>
</ul> </ul>
<div class="submit cf password_entry"> <div class="submit cf password_entry">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment