MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / validate

Method validate

app/src/Licensing/LemonSqueezy.cpp:265–299  ·  view source on GitHub ↗

* @brief Validates the current license key and instance ID. */

Source from the content-addressed store, hash-verified

263 * @brief Validates the current license key and instance ID.
264 */
265void Licensing::LemonSqueezy::validate()
266{
267 if (!canActivate())
268 return;
269
270 if (busy())
271 return;
272
273 m_busy = true;
274 Q_EMIT busyChanged();
275
276 QJsonObject payload;
277 payload.insert("license_key", license());
278 payload.insert("instance_id", instanceId());
279
280 auto url = QUrl("https://api.lemonsqueezy.com/v1/licenses/validate");
281 auto payloadData = QJsonDocument(payload).toJson(QJsonDocument::Compact);
282
283 QNetworkRequest req(url);
284 req.setTransferTimeout(15 * 1000);
285 req.setHeader(QNetworkRequest::ContentTypeHeader, "application/vnd.api+json");
286 req.setRawHeader("Accept", "application/vnd.api+json");
287
288 auto* reply = m_manager.post(req, payloadData);
289 connect(reply, &QNetworkReply::finished, this, [this, reply]() {
290 if (reply->error() != QNetworkReply::NoError)
291 qWarning() << "[LemonSqueezy] Validation network error:" << reply->errorString();
292
293 readValidationResponse(
294 reply->error() == QNetworkReply::NoError ? reply->readAll() : QByteArray(), false);
295 reply->deleteLater();
296
297 writeSettings();
298 });
299}
300
301/**
302 * @brief Deactivates the license on this machine; an offline certificate routes

Callers

nothing calls this directly

Calls 5

errorMethod · 0.80
errorStringMethod · 0.80
QUrlClass · 0.50
toJsonMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected