diff --git a/module/user/js/common.ui.js b/module/user/js/common.ui.js index f15bcac530..bccc6e0f05 100644 --- a/module/user/js/common.ui.js +++ b/module/user/js/common.ui.js @@ -8,45 +8,6 @@ window.switchAccount = function(account) loadPage(link); }; -function computePasswordStrength(password) -{ - if(password.length == 0) return 0; - - var strength = 0; - var length = password.length; - - var complexity = new Array(); - for(i = 0; i < length; i++) - { - letter = password.charAt(i); - var asc = letter.charCodeAt(); - if(asc >= 48 && asc <= 57) - { - complexity[0] = 1; - } - else if((asc >= 65 && asc <= 90)) - { - complexity[1] = 2; - } - else if(asc >= 97 && asc <= 122) - { - complexity[2] = 4; - } - else - { - complexity[3] = 8; - } - } - - var sumComplexity = 0; - for(i in complexity) sumComplexity += complexity[i]; - - if((sumComplexity == 7 || sumComplexity == 15) && password.length >= 6) strength = 1; - if(sumComplexity == 15 && password.length >= 10) strength = 2; - - return strength; -} - /** * Switch account * @@ -68,27 +29,6 @@ $(document).ready(function() }); }); -/** - * Check password strength. - * - * @param event $event - * @access public - * @return void - */ -function checkPassword(event) -{ - let password = $(event.target).val(); - $('#passwordStrength').html(password == '' ? '' : passwordStrengthList[computePasswordStrength(password)]); - if(password == '') - { - $('#passwordStrength').addClass('hidden'); - } - else - { - $('#passwordStrength').removeClass('hidden'); - } -} - /** * Update groups when visions change. * diff --git a/module/user/ui/create.html.php b/module/user/ui/create.html.php index 1f2fc48b31..9120b322ae 100644 --- a/module/user/ui/create.html.php +++ b/module/user/ui/create.html.php @@ -116,22 +116,7 @@ formPanel set::width('1/2'), set::label($lang->user->password), set::required(true), - inputGroup - ( - input - ( - on::keyup('checkPassword'), - set::id('password1'), - set::name('password1'), - set::value(''), - set::placeholder(zget($lang->user->placeholder->passwordStrength, $config->safe->mode, '')), - ), - span - ( - setClass('input-group-addon hidden'), - set::id('passwordStrength'), - ), - ), + password(set::checkStrength(true)), set::tip($passwordStrength), set::tipClass('form-tip') ) diff --git a/module/user/ui/edit.html.php b/module/user/ui/edit.html.php index 12f6e30359..4f8430d23d 100644 --- a/module/user/ui/edit.html.php +++ b/module/user/ui/edit.html.php @@ -188,28 +188,14 @@ formPanel on::change('password1Change'), set::width('1/2'), set::label($lang->user->password), - inputGroup - ( - input - ( - on::keyup('checkPassword'), - set::id('password1'), - set::name('password1'), - set::value(''), - set::placeholder(zget($lang->user->placeholder->passwordStrength, $config->safe->mode, '')), - ), - span - ( - setClass('input-group-addon hidden'), - set::id('passwordStrength'), - ), - ), + password(set::checkStrength(true)), ), formGroup ( on::change('password2Change'), set::width('1/2'), set::label($lang->user->password2), + set::control('password'), set::name('password2'), set::value(''), )