first commit

This commit is contained in:
CN-JS-HuiBai
2026-04-07 16:54:24 +08:00
commit 2c6a38c80d
399 changed files with 42205 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Middleware;
use App\Exceptions\ApiException;
use Closure;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
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', $request->route('token'));
if (empty($token)) {
throw new ApiException('token is null',403);
}
$user = User::where('token', $token)->first();
if (!$user) {
throw new ApiException('token is error',403);
}
Auth::setUser($user);
return $next($request);
}
}