File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ And here is the controller::
398
398
399
399
use Lcobucci\JWT\Builder;
400
400
use Lcobucci\JWT\Signer\Hmac\Sha256;
401
+ use Lcobucci\JWT\Signer\Key;
401
402
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
402
403
use Symfony\Component\HttpFoundation\Request;
403
404
use Symfony\Component\HttpFoundation\Response;
@@ -413,9 +414,8 @@ And here is the controller::
413
414
$username = $this->getUser()->getUsername(); // Retrieve the username of the current user
414
415
$token = (new Builder())
415
416
// set other appropriate JWT claims, such as an expiration date
416
- ->set('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else
417
- ->sign(new Sha256(), $this->getParameter('mercure_secret_key')) // don't forget to set this parameter! Test value: aVerySecretKey
418
- ->getToken();
417
+ ->withClaim('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else
418
+ ->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: aVerySecretKey
419
419
420
420
$response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
421
421
$response->headers->set(
You can’t perform that action at this time.
0 commit comments