src/Auth.php
private function createPasswordResetRequest($userId, $expiresAfter, callable $callback) {
		$selector = self::createRandomString(20);
		$token = self::createRandomString(20);
		$tokenHashed = \password_hash($token, \PASSWORD_DEFAULT);
		$expiresAt = \time() + $expiresAfter;

		try {
			$this->db->insert(
				$this->makeTableNameComponents('users_resets'),
				[
					'user' => $userId,
					'selector' => $selector,
					'token' => $tokenHashed,
					'expires' => $expiresAt
				]
			);
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}

		if (\is_callable($callback)) {
			$callback($selector, $token);
		}
		else {
			throw new MissingCallbackError();
		}
	}
private function createPasswordResetRequest($userId, $expiresAfter, callable $callback) {
		$selector = self::createRandomString(20);
		$token = self::createRandomString(20);
		$tokenHashed = \password_hash($token, \PASSWORD_DEFAULT);
		$expiresAt = \time() + $expiresAfter;

		try {
			$this->db->insert(
				$this->makeTableNameComponents('users_resets'),
				[
					'user' => $userId,
					'selector' => $selector,
					'token' => $tokenHashed,
					'expires' => $expiresAt
				]
			);
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}

		if (\is_callable($callback)) {
			$callback($selector, $token);
		}
		else {
			throw new MissingCallbackError();
		}
	}
private function createPasswordResetRequest ( $ userId , $ expiresAfter , callable $ callback ) { $ selector = self :: createRandomString ( 20 ) ; $ token = self :: createRandomString ( 20 ) ; $ tokenHashed = \ password_hash ( $ token , \ PASSWORD_DEFAULT ) ; $ expiresAt = \ time ( ) + $ expiresAfter ; try { $ this -> db -> insert ( $ this -> makeTableNameComponents ( 'users_resets' ) , [ 'user' => $ userId , 'selector' => $ selector , 'token' => $ tokenHashed , 'expires' => $ expiresAt ] ) ; } catch ( Error $ e ) { throw new DatabaseError ( $ e -> getMessage ( ) ) ; } if ( \ is_callable ( $ callback ) ) { $ callback ( $ selector , $ token ) ; } else { throw new MissingCallbackError ( ) ; } }
Creates a new password reset request

The callback function must have the following signature:

`function ($selector, $token)`

Both pieces of information must be sent to the user, usually embedded in a link

When the user wants to proceed to the second step of the password reset, both pieces will be required again

@param int $userId the ID of the user who requested the reset
@param int $expiresAfter the interval in seconds after which the request should expire
@param callable $callback the function that sends the password reset information to the user
@throws AuthError if an internal problem occurred (do *not* catch)
Creates a new password reset request