implementing zxcvbn in reset-code tpl, re: #6400

This commit is contained in:
Julian Lam
2018-03-26 12:35:51 -04:00
parent 59dc4024b9
commit 9aa9183cc3
2 changed files with 5 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
'use strict';
define('forum/reset_code', function () {
define('forum/reset_code', ['zxcvbn'], function (zxcvbn) {
var ResetCode = {};
ResetCode.init = function () {
@@ -12,10 +12,13 @@ define('forum/reset_code', function () {
var repeat = $('#repeat');
resetEl.on('click', function () {
var strength = zxcvbn(password.val());
if (password.val().length < ajaxify.data.minimumPasswordLength) {
app.alertError('[[reset_password:password_too_short]]');
} else if (password.val() !== repeat.val()) {
app.alertError('[[reset_password:passwords_do_not_match]]');
} else if (strength.score < ajaxify.data.minimumPasswordStrength) {
app.alertError('[[user:weak_password]]');
} else {
resetEl.prop('disabled', true).html('<i class="fa fa-spin fa-refresh"></i> Changing Password');
socket.emit('user.reset.commit', {