validate() public method

validate the password
Since: 2.6.0
public validate ( string $password = null, string $hash = null ) : boolean
$password string plain password
$hash string hashed password
return boolean
 /**
  * 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);
 }
Beispiel #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;
 }