mirror of
https://github.com/v2board/v2board.git
synced 2024-11-15 00:09:13 +08:00
31 lines
631 B
PHP
31 lines
631 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use Closure;
|
||
|
use App\Models\User;
|
||
|
|
||
|
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(500, 'token is null');
|
||
|
}
|
||
|
$user = User::where('token', $token)->first();
|
||
|
if (!$user) {
|
||
|
abort(500, 'token is error');
|
||
|
}
|
||
|
$request->user = $user;
|
||
|
return $next($request);
|
||
|
}
|
||
|
}
|