user = auth('api')->user(); $this->userId = $this->user ? $this->user->id : 0; $user = User::query()->where('id', $this->userId)->where('is_black', 0)->first(); if (!$user) { abort(401); } if ($user->is_black) { abort(402); } Auth::$user = $user; Auth::$userId = $user->id; return $next($request); } }