Authenticates the password.
This is the 'authenticate' validator as declared in rules().
@param string $attribute the name of the attribute to be validated.
@param array $params additional parameters passed with rule when being executed.
511780
public function authenticate($attribute,$params)
	{
		$this->_identity=new UserIdentity('yiier',$this->password);
		if(!$this->_identity->authenticate())
			$this->addError('password','Incorrect password.');
	}
1121222
public function existingIdentity($attribute, $params)
    {
        if ($this->hasErrors()) {
            return false;
        }
        $identity = $this->getIdentity();
        if ($identity === null) {
            if ($this->username !== null) {
                $this->addError('username', Yii::t('usr', 'No user found matching this username.'));
            } elseif ($this->email !== null) {
                $this->addError('email', Yii::t('usr', 'No user found matching this email address.'));
            } else {
                $this->addError('username', Yii::t('usr', 'Please specify username or email.'));
            }

            return false;
        } elseif ($identity->isDisabled()) {
            $this->addError('username', Yii::t('usr', 'User account has been disabled.'));

            return false;
        }

        return true;
    }
435257
public function validateMobileUpdate( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			$existingUser = self::findByMobile( $this->mobile );

			if( isset( $existingUser ) && $this->id != $existingUser->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_MOBILE_EXIST ) );
			}
		}
	}
855244
private function _check_credentials($params){
    if ( $this->check() ){
      /** @var array $f The form fields sent to identify the users */
      $f =& $this->class_cfg['fields'];

      if ( !isset($params[$f['salt']]) ){
        $this->set_error(11);
      }
      else{
        if ( !$this->check_salt($params[$f['salt']]) ){
          $this->set_error(17);
        }
      }
      if ( $this->check() ){
        if ( isset($params[$f['user']], $params[$f['pass']]) ){
          // Table structure
          $arch =& $this->class_cfg['arch'];

          $this->just_login = 1;

          // Database Query
          if (
            $id = $this->db->select_one(
              $this->class_cfg['tables']['users'],
              $this->fields['id'],
              x::merge_arrays(
                $this->class_cfg['conditions'],
                [$arch['users']['active'] => 1],
                [($arch['users']['login'] ?? $arch['users']['email']) => $params[$f['user']]])
            )
          ){
            $pass = $this->db->select_one(
              $this->class_cfg['tables']['passwords'],
              $arch['passwords']['pass'],
              [$arch['passwords']['id_user'] => $id],
              [$arch['passwords']['added'] => 'DESC']);
            if ( $this->_check_password($params[$f['pass']], $pass) ){
              $this->_login($id);
            }
            else{
              $this->record_attempt();
              // Canceling authentication if num_attempts > max_attempts
              $this->set_error($this->check_attempts() ? 6 : 4);
            }
          }
          else{
            $this->set_error(6);
          }
        }
        else{
          $this->set_error(12);
        }
      }
    }
    else{

      die(var_dump($this->get_error()));
    }
    return $this->auth;
  }
230807
public function passwordHasNotExpired($attribute, $params)
    {
        if (($behavior = $this->getBehavior('expiredPasswordBehavior')) !== null) {
            return $behavior->passwordHasNotExpired($attribute, $params);
        }

        return true;
    }
933103
public function validateNewPassword($attribute, $params)
    {
        if ($this->new_password_confirm != $this->new_password) {
            $this->addError($attribute, \Yii::t('skeeks/cms', 'New passwords do not match'));
        }
    }
180690
public function validateParentChain( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( isset( $this->parentId ) && $this->parentId > 0 && $this->parentId == $this->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_PARENT_CHAIN ) );
			}
		}
	}
838252
public function validateTableName($attribute, $params)
    {
        if ($this->hasErrors()) {
            return;
        }

        $invalidTables = array();
        $invalidColumns = array();

        if ($this->tableName[strlen($this->tableName) - 1] === '*') {
            if (($pos = strrpos($this->tableName, '.')) !== false) {
                $schema = substr($this->tableName, 0, $pos);
            } else {
                $schema = '';
            }

            $tables = $this->getDbConnection()->schema->getTables($schema);
            foreach ($tables as $table) {
                if ($this->tablePrefix == '' || strpos($table->name, $this->tablePrefix) === 0) {
                    if ($this->isReservedKeyword($table->name)) {
                        $invalidTables[] = $table->name;
                    }
                    if (($invalidColumn = $this->checkColumns($table)) !== null) {
                        $invalidColumns[] = $invalidColumn;
                    }
                }
            }
        } else {
            if (($table = $this->getTableSchema($this->tableName)) === null) {
                $this->addError('tableName', "Table '{$this->tableName}' does not exist.");
            }

            if (!$this->hasErrors($attribute) && ($invalidColumn = $this->checkColumns($table)) !== null) {
                $invalidColumns[] = $invalidColumn;
            }
        }

        if ($invalidTables != array()) {
            $this->addError(
                'tableName',
                'Model class cannot take a reserved PHP keyword! Table name: ' . implode(', ', $invalidTables) . "."
            );
        }
        if ($invalidColumns != array()) {
            $this->addError(
                'tableName',
                'Column names that does not follow PHP variable naming convention: ' . implode(
                    ', ',
                    $invalidColumns
                ) . "."
            );
        }
    }
417443
public function behaviorValidator($attribute, $params)
    {
        $behavior = $params['behavior'];
        $validator = $params['validator'];
        unset($params['behavior']);
        unset($params['validator']);
        if (($behavior = $this->getBehavior($behavior)) !== null) {
            return $behavior->{$validator}($attribute, $params);
        }

        return true;
    }
1235429
public function validateEmail( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( $this->userService->isExistByEmail( $this->email ) ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_EMAIL_EXIST ) );
			}
		}
	}
1365203
public function validateAttribute($model, $attribute)
    {
        $this->_model = $model;
        $this->_attributeName = $attribute;
        $result = $this->validateValue($model->$attribute);
        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);
        }
    }
279033
public function passes($attribute, $value, $parameters, $validator)
    {
        return Str::is(Str::lower($parameters[0]), Str::lower(parse_url($value, PHP_URL_PATH)));
    }
1125217
public function validatePassword($attribute)
    {
        if (!$this->hasErrors()) {
            if ($this->user === null || !PasswordHelper::validate($this->password, $this->user->password_hash)) {
                $this->addError($attribute, Yii::t('yuncms', 'Invalid login or password'));
            }
        }
    }
1215090
public function validateId($attribute, $params)
    {
        foreach (Yii::$app->user->getLoginPriority() as $item) {
            if ($item::validate($this->$attribute)) {
                return;
            }
        }
        $this->addError($attribute, Yii::t('user', 'Incorrect ID.'));
    }
1179721
protected function doResolveParametersForAttribute($attribute, $parameters)
    {
        $this->attributes[$attribute] = $this->getValueForParameters(
            $parameters,
            $this->attributes[$attribute],
            $this->attributes
        );
    }
636056
public function validateRelation($attribute, $params)
    {
        $relation = $this->getRelation($attribute);
        $attributes = isset($params['attributes']) ? $params['attributes'] : null;
        $errors = [];

        $models = $this->$attribute;
        if (!$relation->multiple) {
            $models = [$models];
        }
        /** @var \yii\db\ActiveRecord[] $models */
        foreach ($models as $index => $model) {
            if (isset($params['scenario'])) {
                $model->scenario = $params['scenario'];
            }

            if ($model->validate($attributes)) {
                continue;
            }
            $errors[] = (string)$model . ': ' . \yii\helpers\Html::errorSummary($model, ['header' => '']) ;
        }

        $this->populateRelation($attribute, $relation->multiple ? $models : $models[0]);
        if (empty($errors)) {
            return;
        }

        $errors = "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>";

        $placeholders = [
            'attribute' => $this->getRelationLabel($relation, $attribute),
        ];
        $message = $relation->multiple
            ? \Yii::t('app', '{attribute} have invalid items:', $placeholders)
            : \Yii::t('app', '{attribute} is invalid:', $placeholders);
        $this->addError($attribute, $message . $errors);
    }
1174336
protected function validateMin( $value, $attribute, array $parameters )
	{
		$this->requireParameterCount( 1, $parameters, 'min' );

		return $this->getSize( $attribute, $value ) >= $parameters[0];
	}