Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

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.

0

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;
    }
}
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

yadhu680 yadhu680 Joined 22 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.