mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-23 11:08:13 -05:00
35 lines
723 B
PHP
35 lines
723 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use App\Utils\CacheKey;
|
||
|
use Closure;
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Support\Facades\Cache;
|
||
|
|
||
|
class Client
|
||
|
{
|
||
|
/**
|
||
|
* Handle an incoming request.
|
||
|
*
|
||
|
* @param \Illuminate\Http\Request $request
|
||
|
* @param \Closure $next
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function handle($request, Closure $next)
|
||
|
{
|
||
|
$token = $request->input('token');
|
||
|
if (empty($token)) {
|
||
|
abort(403, 'token is null');
|
||
|
}
|
||
|
$user = User::where('token', $token)->first();
|
||
|
if (!$user) {
|
||
|
abort(403, 'token is error');
|
||
|
}
|
||
|
$request->merge([
|
||
|
'user' => $user
|
||
|
]);
|
||
|
return $next($request);
|
||
|
}
|
||
|
}
|