private function responseToken($data) { if (is_array($data)) { if ($data['type'] == 'servicio') { $servicio = Servicio::find($data['data']['id_serv']); if (!$servicio->serv_activo) { throw new RestException(__FILE__, "Sin acceso a la plataforma.", 403, ["message" => "Sin acceso a la plataforma."]); } $ips = []; (new Ip())->allThem()->each(function ($item, $key) use(&$ips) { array_push($ips, $item->ipp); }); if (!in_array($_SERVER['REMOTE_ADDR'], $ips)) { throw new RestException(__FILE__, "Ip desconocida.", 403, ["message" => "Ip desconocida."]); } } $token = TokenFromUser::getToken($data); $type = $data['type']; return response()->json(compact("token", "type"), 200); } return null; }