From 958bc64f12001240ab365da3db6ba572ab458301 Mon Sep 17 00:00:00 2001 From: darthf1 Date: Mon, 24 Feb 2020 16:19:45 +0100 Subject: [PATCH] [Mercure] update example with deprecated code In version of `"lcobucci/jwt": "3.3"`, `set()` and `sign()` have been deprecated. This PR updates the example to use the new functions. --- mercure.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mercure.rst b/mercure.rst index b9a738bc13b..0e4d675d5ea 100644 --- a/mercure.rst +++ b/mercure.rst @@ -398,6 +398,7 @@ And here is the controller:: use Lcobucci\JWT\Builder; use Lcobucci\JWT\Signer\Hmac\Sha256; + use Lcobucci\JWT\Signer\Key; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -413,9 +414,8 @@ And here is the controller:: $username = $this->getUser()->getUsername(); // Retrieve the username of the current user $token = (new Builder()) // set other appropriate JWT claims, such as an expiration date - ->set('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else - ->sign(new Sha256(), $this->getParameter('mercure_secret_key')) // don't forget to set this parameter! Test value: aVerySecretKey - ->getToken(); + ->withClaim('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else + ->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: aVerySecretKey $response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']); $response->headers->set(