mobile: add ability to delete cloud account

Apple store rules require this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2022-08-07 17:11:05 -07:00
parent 941aaf5b65
commit 32bc034f41
9 changed files with 159 additions and 0 deletions

View file

@ -17,6 +17,7 @@ CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
#define CLOUDBACKENDSTORAGE CLOUDURL + "/storage"
#define CLOUDBACKENDVERIFY CLOUDURL + "/verify"
#define CLOUDBACKENDUPDATE CLOUDURL + "/update"
#define CLOUDBACKENDDELETE CLOUDURL + "/delete-account"
QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QString& password,const QString& pin,const QString& newpasswd)
{
@ -50,6 +51,34 @@ QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QStr
return reply;
}
QNetworkReply* CloudStorageAuthenticate::deleteAccount(const QString& email, const QString& password)
{
QString payload(email + QChar(' ') + password);
QNetworkRequest *request = new QNetworkRequest(QUrl(CLOUDBACKENDDELETE));
request->setRawHeader("Accept", "text/xml, text/plain");
request->setRawHeader("User-Agent", userAgent.toUtf8());
request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
reply = manager()->post(*request, qPrintable(payload));
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(reply, &QNetworkReply::finished, this, &CloudStorageAuthenticate::deleteFinished);
connect(reply, &QNetworkReply::sslErrors, this, &CloudStorageAuthenticate::sslErrors);
connect(reply, &QNetworkReply::errorOccurred, this, &CloudStorageAuthenticate::uploadError);
#else
connect(reply, SIGNAL(finished()), this, SLOT(deleteFinished()));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(uploadError(QNetworkReply::NetworkError)));
#endif
return reply;
}
void CloudStorageAuthenticate::deleteFinished()
{
QString cloudAuthReply(reply->readAll());
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
emit finishedDelete();
}
void CloudStorageAuthenticate::uploadFinished()
{
static QString myLastError;