validate() 공개 메소드

validate the password
부터: 2.6.0
public validate ( string $password = null, string $hash = null ) : boolean
$password string plain password
$hash string hashed password
리턴 boolean
예제 #1
0
 /**
  * testPassword
  *
  * @since 2.6.0
  *
  * @param string $password
  * @param array $hashArray
  * @param integer $expect
  *
  * @dataProvider providerPassword
  */
 public function testPassword($password = null, $hashArray = [], $expect = null)
 {
     /* setup */
     $validator = new Validator\Password();
     /* actual */
     $actual = $validator->validate($password, function_exists('password_verify') ? $hashArray[0] : $hashArray[1]);
     /* compare */
     $this->assertEquals($expect, $actual);
 }
예제 #2
0
 /**
  * validate
  *
  * @since 3.0.0
  *
  * @param array $postArray array of the post
  * @param object $user object of the user
  *
  * @return array
  */
 protected function _validate($postArray = [], $user = null)
 {
     $passwordValidator = new Validator\Password();
     $captchaValidator = new Validator\Captcha();
     /* validate post */
     $messageArray = [];
     if (!$postArray['user']) {
         $messageArray[] = $this->_language->get('user_empty');
     } else {
         if (!$user->id) {
             $messageArray[] = $this->_language->get('user_incorrect');
         }
     }
     if (!$postArray['password']) {
         $messageArray[] = $this->_language->get('password_empty');
     } else {
         if ($user->password && $passwordValidator->validate($postArray['password'], $user->password) === Validator\ValidatorInterface::FAILED) {
             $messageArray[] = $this->_language->get('password_incorrect');
         }
     }
     if (Db::getSetting('captcha') > 0 && $captchaValidator->validate($postArray['task'], $postArray['solution']) === Validator\ValidatorInterface::FAILED) {
         $messageArray[] = $this->_language->get('captcha_incorrect');
     }
     return $messageArray;
 }