src/Model/Behavior/UserBehavior.php
public function initPasswordReset($value, $options = []) {
		$defaults = [
			'field' => [
				$this->_table->aliasField($this->_field('email')),
				$this->_table->aliasField($this->_field('username'))
			]
		];

		$options = Hash::merge($defaults, $this->_config['initPasswordReset'], $options);
		$result = $this->_getUser($value, $options);

		if (empty($result)) {
			throw new RecordNotFoundException(__d('burzum/user_tools', 'User not found.'));
		}

		$result->set([
			$this->_field('passwordToken') => $this->generateToken($options['tokenLength']),
			$this->_field('passwordTokenExpires') => $this->expirationTime($options['expires'])
		], [
			'guard' => false
		]);

		if (!$this->_table->save($result, ['checkRules' => false])) {
			new RuntimeException('Could not initialize password reset. Data could not be saved.');
		}

		$this->sendPasswordResetToken($result, [
			'to' => $result->get($this->_field('email'))
		]);
	}
public function initPasswordReset($value, $options = []) {
		$defaults = [
			'field' => [
				$this->_table->aliasField($this->_field('email')),
				$this->_table->aliasField($this->_field('username'))
			]
		];

		$options = Hash::merge($defaults, $this->_config['initPasswordReset'], $options);
		$result = $this->_getUser($value, $options);

		if (empty($result)) {
			throw new RecordNotFoundException(__d('burzum/user_tools', 'User not found.'));
		}

		$result->set([
			$this->_field('passwordToken') => $this->generateToken($options['tokenLength']),
			$this->_field('passwordTokenExpires') => $this->expirationTime($options['expires'])
		], [
			'guard' => false
		]);

		if (!$this->_table->save($result, ['checkRules' => false])) {
			new RuntimeException('Could not initialize password reset. Data could not be saved.');
		}

		$this->sendPasswordResetToken($result, [
			'to' => $result->get($this->_field('email'))
		]);
	}
public function initPasswordReset ( $ value , $ options = [ ] ) { $ defaults = [ 'field' => [ $ this -> _table -> aliasField ( $ this -> _field ( 'email' ) ) , $ this -> _table -> aliasField ( $ this -> _field ( 'username' ) ) ] ] ; $ options = Hash :: merge ( $ defaults , $ this -> _config [ 'initPasswordReset' ] , $ options ) ; $ result = $ this -> _getUser ( $ value , $ options ) ; if ( empty ( $ result ) ) { throw new RecordNotFoundException ( __d ( 'burzum/user_tools' , 'User not found.' ) ) ; } $ result -> set ( [ $ this -> _field ( 'passwordToken' ) => $ this -> generateToken ( $ options [ 'tokenLength' ] ) , $ this -> _field ( 'passwordTokenExpires' ) => $ this -> expirationTime ( $ options [ 'expires' ] ) ] , [ 'guard' => false ] ) ; if ( ! $ this -> _table -> save ( $ result , [ 'checkRules' => false ] ) ) { new RuntimeException ( 'Could not initialize password reset. Data could not be saved.' ) ; } $ this -> sendPasswordResetToken ( $ result , [ 'to' => $ result -> get ( $ this -> _field ( 'email' ) ) ] ) ; }
Initializes a password reset process.

@param mixed $value User id or other value to look the user up
@param array $options Options
@return void
Initializes a password reset process .