From a65bf3a14b617d4af6749bab9e6ac7668fb99292 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 06 Feb 2010 12:59:41 -0500
Subject: [PATCH] - Password: fix vpopmaild driver (#1486478)

---
 plugins/password/password.php |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/plugins/password/password.php b/plugins/password/password.php
index 83af68b..4f34e40 100644
--- a/plugins/password/password.php
+++ b/plugins/password/password.php
@@ -3,7 +3,7 @@
 /*
  +-------------------------------------------------------------------------+
  | Password Plugin for Roundcube                                           |
- | Version 1.3.1                                                           |
+ | Version 1.3.2                                                           |
  |                                                                         |
  | Copyright (C) 2009, RoundCube Dev.                                      |
  |                                                                         |
@@ -42,7 +42,6 @@
  *
  * For installation and configuration instructions please read the README file.
  *
- * @version 1.3.1
  * @author Aleksander Machniak
  */
 class password extends rcube_plugin
@@ -79,20 +78,36 @@
     $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);
+      $conpwd = get_input_value('_confpasswd', RCUBE_INPUT_POST);
 
-      if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd)
+      if ($conpwd != $newpwd) {
+        $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error');
+      }
+      else 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);
-      } else
+      }
+      else
         $rcmail->output->command('display_message', $res, 'error');
     }
 
@@ -142,9 +157,9 @@
     $table->add('title', html::label($field_id, Q($this->gettext('confpasswd'))));
     $table->add(null, $input_confpasswd->show());
 
-    $out = html::div(array('class' => "settingsbox", 'style' => "margin:0"),
-      html::div(array('id' => "userprefs-title"), $this->gettext('changepasswd')) .
-      html::div(array('style' => "padding:15px"), $table->show() .
+    $out = html::div(array('class' => 'settingsbox', 'style' => 'margin:0'),
+      html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('changepasswd')) .
+      html::div(array('class' => 'boxcontent'), $table->show() .
         html::p(null,
           $rcmail->output->button(array(
             'command' => 'plugin.password-save',

--
Gitblit v1.9.1