22 lines
511 B
PHP
22 lines
511 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use Illuminate\Http\Request;
|
||
|
use Symfony\Component\HttpFoundation\Response;
|
||
|
|
||
|
class CreateClientTokenMiddlewire
|
||
|
{
|
||
|
public function handle(Request $request, \Closure $next): Response
|
||
|
{
|
||
|
$token = $this->createGuestToken($request);
|
||
|
$request->merge(['clientToken' => $token]);
|
||
|
return $next($request);
|
||
|
}
|
||
|
|
||
|
public function createGuestToken(Request $request)
|
||
|
{
|
||
|
return sha1($request->ip() . $request->header('User-Agent'));
|
||
|
}
|
||
|
}
|