Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Created November 6, 2018 17:00
Show Gist options
  • Save IgorDePaula/db305b18913ac4d12c1fd77f2ecbd878 to your computer and use it in GitHub Desktop.
Save IgorDePaula/db305b18913ac4d12c1fd77f2ecbd878 to your computer and use it in GitHub Desktop.
<?php
namespace Tandle\Http\Middleware;
use Closure;
use JWTAuth;
class RefreshTokenMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$token = JWTAuth::refresh();
$response = $next($request);
$response->headers->set('NewToken',$token);
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment