diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-09-11 13:12:43 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-09-11 13:12:43 +0000 |
| commit | 9a96dd619718de03f94d87fbbb33ca315085d917 (patch) | |
| tree | f4cccf4da521122f637377619dbf665b89e93097 /roundcubemail/plugins/password/password.php | |
| parent | 3f2dda319ceb9a31415d5218f92c5be2c723dad9 (diff) | |
- Password: added password strength options (#1486062)
git-svn-id: https://svn.roundcube.net/trunk@2945 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/plugins/password/password.php')
| -rw-r--r-- | roundcubemail/plugins/password/password.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/roundcubemail/plugins/password/password.php b/roundcubemail/plugins/password/password.php index 0e5e1efff..3a7050bdc 100644 --- a/roundcubemail/plugins/password/password.php +++ b/roundcubemail/plugins/password/password.php @@ -79,16 +79,27 @@ class password extends rcube_plugin $rcmail->output->set_pagetitle($this->gettext('changepasswd')); $confirm = $rcmail->config->get('password_confirm_current'); + $required_length = intval($rcmail->config->get('password_minimum_length')); + $check_strength = $rcmail->config->get('password_require_nonalpha'); if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) { $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error'); } else { + $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST); $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST); - if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) + if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) { $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); + } + else if ($required_length && strlen($newpwd) < $required_length) { + $rcmail->output->command('display_message', $this->gettext( + array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error'); + } + else if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) { + $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error'); + } else if (!($res = $this->_save($curpwd,$newpwd))) { $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); $_SESSION['password'] = $rcmail->encrypt($newpwd); |
