ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10620


Ignore:
Timestamp:
Feb 4, 2009, 1:26:04 PM (11 years ago)
Author:
nagasawa
Message:

#3262,#3263:fixed the password form validators

Location:
OpenPNE3/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/mobile_frontend/i18n/messages.ja.xml

    r10545 r10620  
    291291        <target>前のページに戻る</target>
    292292      </trans-unit>
    293     </body>
     293      <trans-unit id="">
     294        <source>Please input by a-z or A-Z or 6-12 characters and 6-12 length.</source>
     295        <target>6~12文字の半角英数で入力してください。</target>
     296      </trans-unit>
     297     </body>
    294298  </file>
    295299</xliff>
  • OpenPNE3/trunk/apps/pc_frontend/i18n/messages.ja.xml

    r10582 r10620  
    467467        <target>これ以上画像を追加できません。</target>
    468468      </trans-unit>
    469     </body>
     469      <trans-unit id="">
     470        <source>Please input by a-z or A-Z or 6-12 characters and 6-12 length.</source>
     471        <target>6~12文字の半角英数で入力してください。</target>
     472      </trans-unit>
     473     </body>
    470474  </file>
    471475</xliff>
  • OpenPNE3/trunk/lib/form/MemberConfigForm.class.php

    r10545 r10620  
    8787      $this->widgetSchema->setLabel($name.'_confirm', $config['Caption'].' (Confirm)');
    8888
    89       $this->mergePostValidator(new sfValidatorSchemaCompare($name, '==', $name.'_confirm'));
     89      $this->mergePostValidator(new sfValidatorSchemaCompare($name.'_confirm', '==', $name));
    9090    }
    9191
  • OpenPNE3/trunk/lib/form/MemberConfigForm/MemberConfigPasswordForm.class.php

    r10455 r10620  
    2323  {
    2424    $this->setWidget('now_password', new sfWidgetFormInputPassword());
    25     $this->setValidator('now_password', new sfValidatorCallback(array('callback' => array($this, 'isValidPassword'))));
     25    $this->setValidator(
     26      'now_password',
     27      new sfValidatorCallback(
     28        array('callback' => array($this, 'isValidNowPassword'), 'required' => true)
     29      )
     30    );
    2631    $this->widgetSchema->setLabel('now_password', 'Your current password');
     32  }
     33
     34  public function setMemberConfigWidget($name)
     35  {
     36    $result = parent::setMemberConfigWidget($name);
     37
     38    if ($name === 'password')
     39    {
     40      $this->setValidator( $name, new sfValidatorCallback(array(
     41        'callback'  => array($this, 'isValidPassword'),
     42        'required' => true
     43      )));
     44    }
     45
     46    return $result;
     47  }
     48
     49  public function isValidNowPassword($validator, $value)
     50  {
     51    $member = sfContext::getInstance()->getUser()->getMember();
     52    if (md5($value) !== MemberConfigPeer::retrieveByNameAndMemberId('password', $member->getId())->getValue())
     53    {
     54      throw new sfValidatorError(new sfValidatorPass(), 'Invalid.', array('value' => $value));
     55    }
     56
     57    return $value;
    2758  }
    2859
    2960  public function isValidPassword($validator, $value)
    3061  {
    31     $member = sfContext::getInstance()->getUser()->getMember();
    32     if (md5($value) !== MemberConfigPeer::retrieveByNameAndMemberId('password', $member->getId())->getValue())
     62    $size = strlen($value);
     63    if (!preg_match("/^[a-zA-Z0-9]+$/", $value) || $size < 6 || $size > 12)
    3364    {
    34       throw new sfValidatorError(new sfValidatorPass(), 'invalid', array('value' => $value));
     65      throw new sfValidatorError(new sfValidatorPass(), 'Please input by a-z or A-Z or 6-12 characters and 6-12 length.', array('value' => $value));
    3566    }
    3667
    3768    return $value;
    3869  }
     70
     71  public function save()
     72  {
     73    $this->values['password'] = md5($this->values['password']);
     74    parent::save();
     75  }
    3976}
Note: See TracChangeset for help on using the changeset viewer.