refresh token cannot be generated after original token expire. For security reasons, you must generate the new token before old one is expired. If you are using mobile app, then you can generate refresh token everytime user opens the app, and then after ever one hour. In that case, ttl for token expiry should be more than one hours.
you can use this middleware it return a new token in Header
<?php
namespace App\Http\Middleware;
use app\OpenTest\Functions;
use Closure;
class RefreshToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('NewToken',Functions::RefreshToken());
return $response;
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community