mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36: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;
|
passwordvalid = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
utils.assertPasswordValidity(password.val());
|
utils.assertPasswordValidity(password.val(), zxcvbn);
|
||||||
|
|
||||||
if (password.val() === ajaxify.data.username) {
|
if (password.val() === ajaxify.data.username) {
|
||||||
throw new Error('[[user:password_same_as_username]]');
|
throw new Error('[[user:password_same_as_username]]');
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/register', [
|
define('forum/register', [
|
||||||
'translator', 'slugify', 'api', 'bootbox', 'forum/login', 'jquery-form',
|
'translator', 'slugify', 'api', 'bootbox', 'forum/login', 'jquery-form', 'zxcvbn',
|
||||||
], function (translator, slugify, api, bootbox, Login) {
|
], function (translator, slugify, api, bootbox, Login, zxcvbn) {
|
||||||
const Register = {};
|
const Register = {};
|
||||||
let validationError = false;
|
let validationError = false;
|
||||||
const successIcon = '';
|
const successIcon = '';
|
||||||
@@ -143,7 +143,7 @@ define('forum/register', [
|
|||||||
const password_confirm_notify = $('#password-confirm-notify');
|
const password_confirm_notify = $('#password-confirm-notify');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
utils.assertPasswordValidity(password);
|
utils.assertPasswordValidity(password, zxcvbn);
|
||||||
|
|
||||||
if (password === $('#username').val()) {
|
if (password === $('#username').val()) {
|
||||||
throw new Error('[[user:password_same_as_username]]');
|
throw new Error('[[user:password_same_as_username]]');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/reset_code', ['alerts'], function (alerts) {
|
define('forum/reset_code', ['alerts', 'zxcvbn'], function (alerts, zxcvbn) {
|
||||||
const ResetCode = {};
|
const ResetCode = {};
|
||||||
|
|
||||||
ResetCode.init = function () {
|
ResetCode.init = function () {
|
||||||
@@ -13,7 +13,7 @@ define('forum/reset_code', ['alerts'], function (alerts) {
|
|||||||
|
|
||||||
resetEl.on('click', function () {
|
resetEl.on('click', function () {
|
||||||
try {
|
try {
|
||||||
utils.assertPasswordValidity(password.val());
|
utils.assertPasswordValidity(password.val(), zxcvbn);
|
||||||
|
|
||||||
if (password.val() !== repeat.val()) {
|
if (password.val() !== repeat.val()) {
|
||||||
throw new Error('[[reset_password:passwords_do_not_match]]');
|
throw new Error('[[reset_password:passwords_do_not_match]]');
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
const zxcvbn = require('zxcvbn');
|
|
||||||
|
|
||||||
const utils = { ...require('./utils.common') };
|
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()
|
// More checks on top of basic utils.isPasswordValid()
|
||||||
if (!utils.isPasswordValid(password)) {
|
if (!utils.isPasswordValid(password)) {
|
||||||
throw new Error('[[user:change_password_error]]');
|
throw new Error('[[user:change_password_error]]');
|
||||||
|
|||||||
Reference in New Issue
Block a user