Author: sevein
Date: Mon Jan 30 10:24:03 2012
New Revision: 10775

Log:
Same password behavior in editPassword page

Modified:
   trunk/apps/qubit/modules/user/actions/passwordEditAction.class.php

Modified: trunk/apps/qubit/modules/user/actions/passwordEditAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/user/actions/passwordEditAction.class.php  Mon Jan 
30 10:23:30 2012        (r10774)
+++ trunk/apps/qubit/modules/user/actions/passwordEditAction.class.php  Mon Jan 
30 10:24:03 2012        (r10775)
@@ -28,7 +28,7 @@
   protected function earlyExecute()
   {
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
-    $this->form->getValidatorSchema()->setPostValidator(new 
sfValidatorSchemaCompare(
+    $this->form->getValidatorSchema()->setPreValidator(new 
sfValidatorSchemaCompare(
       'password', '==', 'confirmPassword',
       array(),
       array('invalid' => $this->context->i18n->__('Your password confirmation 
did not match you password.'))));
@@ -53,12 +53,28 @@
   {
     switch ($name)
     {
-      case 'confirmPassword':
       case 'password':
+        $this->form->setDefault('password', null);
+
+        // Use QubitValidatorPassword only when strong passwords are required
+        if (sfConfig::get('app_require_strong_passwords'))
+        {
+          $this->form->setValidator('password', new QubitValidatorPassword(
+            array(),
+            array('invalid' => $this->context->i18n->__('Your password is not 
strong enough.'),
+                  'min_length' => $this->context->i18n->__('Your password is 
not strong enough (too short).'))));
+        }
+        else
+        {
+          $this->form->setValidator('confirmPassword', new 
sfValidatorString(array('required' => !isset($this->getRoute()->resource))));
+        }
 
-        $this->form->setDefault($name, null);
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormInputPassword);
+        $this->form->setWidget('password', new sfWidgetFormInputPassword);
+
+      case 'confirmPassword':
+        $this->form->setDefault('confirmPassword', null);
+        $this->form->setValidator('confirmPassword', new sfValidatorString);
+        $this->form->setWidget('confirmPassword', new 
sfWidgetFormInputPassword);
 
         break;
     }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to