/** * Método estético para verificar el arreglo. * * Se debe pasar el arreglo del usuario, si el usuario es válido retorna un nuevo token. * * @param array $dataUser Contiene el arreglo con el que trabajará. * * @return string * */ public static function verify($dataUser = null) { $instance = new static($dataUser); if (!$instance->checkStructure()) { return false; } if (!$instance->onTime()) { return false; } if (!$instance->exists()) { return false; } return TokenFromUser::getToken($instance->dataUser); }
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; }