mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	implementing zxcvbn in reset-code tpl, re: #6400
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| 'use strict'; | 'use strict'; | ||||||
|  |  | ||||||
|  |  | ||||||
| define('forum/reset_code', function () { | define('forum/reset_code', ['zxcvbn'], function (zxcvbn) { | ||||||
| 	var	ResetCode = {}; | 	var	ResetCode = {}; | ||||||
|  |  | ||||||
| 	ResetCode.init = function () { | 	ResetCode.init = function () { | ||||||
| @@ -12,10 +12,13 @@ define('forum/reset_code', function () { | |||||||
| 		var repeat = $('#repeat'); | 		var repeat = $('#repeat'); | ||||||
|  |  | ||||||
| 		resetEl.on('click', function () { | 		resetEl.on('click', function () { | ||||||
|  | 			var strength = zxcvbn(password.val()); | ||||||
| 			if (password.val().length < ajaxify.data.minimumPasswordLength) { | 			if (password.val().length < ajaxify.data.minimumPasswordLength) { | ||||||
| 				app.alertError('[[reset_password:password_too_short]]'); | 				app.alertError('[[reset_password:password_too_short]]'); | ||||||
| 			} else if (password.val() !== repeat.val()) { | 			} else if (password.val() !== repeat.val()) { | ||||||
| 				app.alertError('[[reset_password:passwords_do_not_match]]'); | 				app.alertError('[[reset_password:passwords_do_not_match]]'); | ||||||
|  | 			} else if (strength.score < ajaxify.data.minimumPasswordStrength) { | ||||||
|  | 				app.alertError('[[user:weak_password]]'); | ||||||
| 			} else { | 			} else { | ||||||
| 				resetEl.prop('disabled', true).html('<i class="fa fa-spin fa-refresh"></i> Changing Password'); | 				resetEl.prop('disabled', true).html('<i class="fa fa-spin fa-refresh"></i> Changing Password'); | ||||||
| 				socket.emit('user.reset.commit', { | 				socket.emit('user.reset.commit', { | ||||||
|   | |||||||
| @@ -50,6 +50,7 @@ Controllers.reset = function (req, res, next) { | |||||||
| 					displayExpiryNotice: req.session.passwordExpired, | 					displayExpiryNotice: req.session.passwordExpired, | ||||||
| 					code: req.params.code, | 					code: req.params.code, | ||||||
| 					minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10), | 					minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10), | ||||||
|  | 					minimumPasswordStrength: parseInt(meta.config.minimumPasswordStrength, 10), | ||||||
| 					breadcrumbs: helpers.buildBreadcrumbs([ | 					breadcrumbs: helpers.buildBreadcrumbs([ | ||||||
| 						{ | 						{ | ||||||
| 							text: '[[reset_password:reset_password]]', | 							text: '[[reset_password:reset_password]]', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user