mirror of
https://github.com/v2board/v2board.git
synced 2024-11-14 07:29:13 +08:00
33 lines
689 B
PHP
Executable File
33 lines
689 B
PHP
Executable File
<?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->user = $user;
|
|
return $next($request);
|
|
}
|
|
}
|