pos-gis/app/Http/Middleware/IdleScreenTimeout.php
2024-10-07 13:13:42 +07:00

41 lines
1.1 KiB
PHP

<?php
namespace App\Http\Middleware;
use Closure;
class IdleScreenTimeout
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// TODO idle screen time
$appsToken = session()->get("AppsToken");
if ($appsToken != null){
$lastIdleTime = session()->get("lastIdleTime");
if ($lastIdleTime == null){
session()->put('lastIdleTime', time());
}else{
if (time() - $lastIdleTime > 60){
session()->forget("lastIdleTime");
return redirect("/");
}
}
}else{
$request->session()->flush();
return redirect('/login');
}
// return $next($request);
$response = $next($request);
return $response->header('Cache-Control','no-cache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
}
}