Piwik\Plugins\Login\PasswordResetter::generatePasswordResetToken PHP Method

generatePasswordResetToken() public method

The reset token is generated using a user's email, login and the time when the token expires.
public generatePasswordResetToken ( array $user, integer | null $expiryTimestamp = null ) : string
$user array The user information.
$expiryTimestamp integer | null The expiration timestamp to use or null to generate one from the current timestamp.
return string The generated token.
    public function generatePasswordResetToken($user, $expiryTimestamp = null)
    {
        /*
         * Piwik does not store the generated password reset token.
         * This avoids a database schema change and SQL queries to store, retrieve, and purge (expired) tokens.
         */
        if (!$expiryTimestamp) {
            $expiryTimestamp = $this->getDefaultExpiryTime();
        }
        $expiry = strftime('%Y%m%d%H', $expiryTimestamp);
        $token = $this->generateSecureHash($expiry . $user['login'] . $user['email'], $user['password']);
        return $token;
    }