I have a Symfony application that uses lexik/LexikJWTAuthenticationBundle
. Can I set configuration to force expiration after midnight?
How can I force expiration date at midnight of current day?
I have a Symfony application that uses lexik/LexikJWTAuthenticationBundle
. Can I set configuration to force expiration after midnight?
How can I force expiration date at midnight of current day?
The right thing to do is to read the documentation. Where they says to ...
services: acme_api.event.jwt_created_listener: class: AppBundle\EventListener\JWTCreatedListener arguments: [ '@request_stack' ] tags: - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }
<?php namespace AppBundle\EventListener; use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent; class JWTCreatedListener { public function onJWTCreated(JWTCreatedEvent $event) { $expiration = new \DateTime(date('d-m-Y')); $expiration->add(new DateInterval('PT86400S')) $payload = $event->getData(); $payload['exp'] = $expiration->getTimestamp(); $event->setData($payload); } }