lexik/LexikJWTAuthenticationBundle — pull request #15 by gfreeau (2014-07-11 02:00:19+00:00)
Title: Added JWT Creator service

I have split out the code that creates a JWT from the authentication success handler.

This is really important in my application for two reasons.

It allows you to easily customize the payload, for example:

```php
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent;

class JWTCreatedListener
{
public function onJWTCreated(JWTCreatedEvent $event)
{
$payload = $event->getData();

$payload['ip'] = $_SERVER['REMOTE_ADDR'];

$event->setData($payload);
}
}
```

Shows a quick example to add an IP address to the payload.

Secondly, it allows you to create a JWT in other parts of the application.

In my angularjs app, I need the ability to refresh the token. By having a separate JWT creation service, I can achieve this easily.