2023-11-17 14:44:01 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2023-12-04 20:40:49 +08:00
|
|
|
use App\Exceptions\ApiException;
|
2023-11-17 14:44:01 +08:00
|
|
|
use App\Services\AuthService;
|
2025-01-07 01:20:11 +08:00
|
|
|
use Auth;
|
2023-11-17 14:44:01 +08:00
|
|
|
use Closure;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class User
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
2025-01-07 01:20:11 +08:00
|
|
|
if (!Auth::guard('sanctum')->check()) {
|
|
|
|
throw new ApiException('未登录或登陆已过期', 403);
|
|
|
|
}
|
2023-11-17 14:44:01 +08:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|