src/Model/UserValidationTrait.php
public function validateOldPassword($value, $field, $context) {
		if (Configure::read('debug') > 0 && empty($context['data'][$this->_table->getPrimaryKey()])) {
			throw new RuntimeException('The user id is required as well to validate the old password!');
		}

		$result = $this->_table->find()
			->select([
				$this->_table->aliasField($field)
			])
			->where([
				$this->_table->getPrimaryKey() => $context['data'][$this->_table->getPrimaryKey()],
			])
			->first();

		if (!$result) {
			return false;
		}

		return $this->getPasswordHasher()->check($value, $result->get($field));
	}
public function validateOldPassword($value, $field, $context) {
		if (Configure::read('debug') > 0 && empty($context['data'][$this->_table->getPrimaryKey()])) {
			throw new RuntimeException('The user id is required as well to validate the old password!');
		}

		$result = $this->_table->find()
			->select([
				$this->_table->aliasField($field)
			])
			->where([
				$this->_table->getPrimaryKey() => $context['data'][$this->_table->getPrimaryKey()],
			])
			->first();

		if (!$result) {
			return false;
		}

		return $this->getPasswordHasher()->check($value, $result->get($field));
	}
public function validateOldPassword ( $ value , $ field , $ context ) { if ( Configure :: read ( 'debug' ) > 0 && empty ( $ context [ 'data' ] [ $ this -> _table -> getPrimaryKey ( ) ] ) ) { throw new RuntimeException ( 'The user id is required as well to validate the old password!' ) ; } $ result = $ this -> _table -> find ( ) -> select ( [ $ this -> _table -> aliasField ( $ field ) ] ) -> where ( [ $ this -> _table -> getPrimaryKey ( ) => $ context [ 'data' ] [ $ this -> _table -> getPrimaryKey ( ) ] , ] ) -> first ( ) ; if ( ! $ result ) { return false ; } return $ this -> getPasswordHasher ( ) -> check ( $ value , $ result -> get ( $ field ) ) ; }
Validation method for the old password.

This method will hash the old password and compare it to the stored hash
in the database. You don't have to hash it manually before validating.

@param mixed $value Value
@param string $field Field
@param mixed $context Context
@return bool
Validation method for the old password .