mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:04:59 +08:00
Review Changes for f4f8a293e7
.
This commit is contained in:
@ -26,16 +26,21 @@ acceptance("Password Reset", {
|
||||
});
|
||||
|
||||
server.get('/u/confirm-email-token/requiretwofactor.json', () => { //eslint-disable-line
|
||||
return response({success: "OK"});
|
||||
return response({ success: "OK" });
|
||||
});
|
||||
|
||||
server.put('/u/password-reset/requiretwofactor.json', request => { //eslint-disable-line
|
||||
const body = parsePostData(request.requestBody);
|
||||
if (body.password === "perf3ctly5ecur3" && body.second_factor_token === "123123") {
|
||||
return response({success: "OK", message: I18n.t('password_reset.success')});
|
||||
return response({ success: "OK", message: I18n.t('password_reset.success') });
|
||||
} else if (body.second_factor_token === "123123") {
|
||||
return response({success: false, errors: {password: ["invalid"]}});
|
||||
return response({ success: false, errors: { password: ["invalid"] } });
|
||||
} else {
|
||||
return response({success: false, message: "invalid token", errors: {second_factor: ["invalid token"]}});
|
||||
return response({
|
||||
success: false,
|
||||
message: "invalid token",
|
||||
errors: { user_second_factor: ["invalid token"] }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -75,24 +80,33 @@ QUnit.test("Password Reset Page", assert => {
|
||||
});
|
||||
|
||||
QUnit.test("Password Reset Page With Second Factor", assert => {
|
||||
PreloadStore.store('password_reset', {is_developer: false, second_factor_required: true});
|
||||
PreloadStore.store('password_reset', {
|
||||
is_developer: false,
|
||||
second_factor_required: true
|
||||
});
|
||||
|
||||
visit("/u/password-reset/requiretwofactor");
|
||||
|
||||
andThen(() => {
|
||||
assert.notOk(exists("#new-account-password"), "does not show the input");
|
||||
assert.ok(exists("#second-factor"), "shows the second factor prompt");
|
||||
});
|
||||
|
||||
fillIn('#second-factor', '0000');
|
||||
|
||||
click('.password-reset form button');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".alert-error"), "shows 2 factor error");
|
||||
assert.ok(find(".alert-error").html().indexOf("invalid token") > -1, "server validation error message shows");
|
||||
|
||||
assert.ok(
|
||||
find(".alert-error").html().indexOf("invalid token") > -1,
|
||||
"shows server validation error message"
|
||||
);
|
||||
});
|
||||
|
||||
fillIn('#second-factor', '123123');
|
||||
click('.password-reset form button');
|
||||
|
||||
andThen(() => {
|
||||
assert.notOk(exists(".alert-error"), "hides error");
|
||||
assert.ok(exists("#new-account-password"), "shows the input");
|
||||
@ -100,6 +114,7 @@ QUnit.test("Password Reset Page With Second Factor", assert => {
|
||||
|
||||
fillIn('.password-reset input', 'perf3ctly5ecur3');
|
||||
click('.password-reset form button');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".password-reset form"), "form is gone");
|
||||
});
|
||||
|
Reference in New Issue
Block a user