mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
breaking: reduce nodebb.min.js size by around 800kb
const zxcvbn = require('zxcvbn');
bundles a huge amount of code, now it won't be in nodebb.min.js
This commit is contained in:
@@ -24,7 +24,7 @@ define('forum/account/edit/password', [
|
||||
passwordvalid = false;
|
||||
|
||||
try {
|
||||
utils.assertPasswordValidity(password.val());
|
||||
utils.assertPasswordValidity(password.val(), zxcvbn);
|
||||
|
||||
if (password.val() === ajaxify.data.username) {
|
||||
throw new Error('[[user:password_same_as_username]]');
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
|
||||
define('forum/register', [
|
||||
'translator', 'slugify', 'api', 'bootbox', 'forum/login', 'jquery-form',
|
||||
], function (translator, slugify, api, bootbox, Login) {
|
||||
'translator', 'slugify', 'api', 'bootbox', 'forum/login', 'jquery-form', 'zxcvbn',
|
||||
], function (translator, slugify, api, bootbox, Login, zxcvbn) {
|
||||
const Register = {};
|
||||
let validationError = false;
|
||||
const successIcon = '';
|
||||
@@ -143,7 +143,7 @@ define('forum/register', [
|
||||
const password_confirm_notify = $('#password-confirm-notify');
|
||||
|
||||
try {
|
||||
utils.assertPasswordValidity(password);
|
||||
utils.assertPasswordValidity(password, zxcvbn);
|
||||
|
||||
if (password === $('#username').val()) {
|
||||
throw new Error('[[user:password_same_as_username]]');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('forum/reset_code', ['alerts'], function (alerts) {
|
||||
define('forum/reset_code', ['alerts', 'zxcvbn'], function (alerts, zxcvbn) {
|
||||
const ResetCode = {};
|
||||
|
||||
ResetCode.init = function () {
|
||||
@@ -13,7 +13,7 @@ define('forum/reset_code', ['alerts'], function (alerts) {
|
||||
|
||||
resetEl.on('click', function () {
|
||||
try {
|
||||
utils.assertPasswordValidity(password.val());
|
||||
utils.assertPasswordValidity(password.val(), zxcvbn);
|
||||
|
||||
if (password.val() !== repeat.val()) {
|
||||
throw new Error('[[reset_password:passwords_do_not_match]]');
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
'use strict';
|
||||
|
||||
const $ = require('jquery');
|
||||
const zxcvbn = require('zxcvbn');
|
||||
|
||||
const utils = { ...require('./utils.common') };
|
||||
|
||||
@@ -57,7 +56,7 @@ utils.isMobile = function () {
|
||||
});
|
||||
};
|
||||
|
||||
utils.assertPasswordValidity = (password) => {
|
||||
utils.assertPasswordValidity = (password, zxcvbn) => {
|
||||
// More checks on top of basic utils.isPasswordValid()
|
||||
if (!utils.isPasswordValid(password)) {
|
||||
throw new Error('[[user:change_password_error]]');
|
||||
|
||||
Reference in New Issue
Block a user