Event listeners in lumen
When started working with lumen for toke based auth I am using the tymon/jwt-auth package. https://github.com/tymondesigns/jwt-auth
The problem I am facing is that when using the jwt.auth filter, it fires certain events that allow us to return cutom error responses. I had registered the event listeners in the EventServiceProvider class and uncommented the line that registers that service provider in the bootstrap/app.php file.
When I do a dd('sample') in the register method of the EventServiceProvider it does dump sample in the console. So the event listeners are not setting up correctly. Any ideas on why this might be happening ?
In the register method of the EventServiceProvider I have the following code.
$this->app['events']->listen('tymon.jwt.expired', function()
{
return response()->json(['success' => false,'errors' => ['Your token has expired.']], 401);
});
$this->app['events']->listen('tymon.jwt.invalid', function()
{
return response()->json(['success' => false,'errors' => ['Your token is invalid.']], 400);
});
$this->app['events']->listen('tymon.jwt.absent', function()
{
return response()->json(['success' => false,'errors' => ['Please provide a token.']],400);
});
Please or to participate in this conversation.