aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-09 11:21:46 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-09 17:04:30 -0700
commit57507cfb93984e520fdd9545c84ea3b921c2914e (patch)
tree1439eb76eca2d6effd65f68c4a7b4feb851444c6 /qt-ui/subsurfacewebservices.cpp
parenta04f1fd13317034c471ad7eb8dbf55375566f947 (diff)
downloadsubsurface-57507cfb93984e520fdd9545c84ea3b921c2914e.tar.gz
Cloud storage: implement confirmation of email address via PIN
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/subsurfacewebservices.cpp')
-rw-r--r--qt-ui/subsurfacewebservices.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index f0208db53..6aadc2de7 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -935,15 +935,25 @@ CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) : QObject(pa
}
-#define CLOUDBACKEND "https://cloud.subsurface-divelog.org/storage"
+#define CLOUDURL "https://cloud.subsurface-divelog.org/"
+#define CLOUDBACKENDSTORAGE CLOUDURL "storage"
+#define CLOUDBACKENDVERIFY CLOUDURL "verify"
-QNetworkReply* CloudStorageAuthenticate::authenticate(QString email, QString password)
+QNetworkReply* CloudStorageAuthenticate::authenticate(QString email, QString password, QString pin)
{
- QNetworkRequest *request = new QNetworkRequest(QUrl(CLOUDBACKEND));
+ QString payload(email + " " + password);
+ QUrl requestUrl;
+ if (pin == "") {
+ requestUrl = QUrl(CLOUDBACKENDSTORAGE);
+ } else {
+ requestUrl = QUrl(CLOUDBACKENDVERIFY);
+ payload += " " + pin;
+ }
+ QNetworkRequest *request = new QNetworkRequest(requestUrl);
request->setRawHeader("Accept", "text/xml, text/plain");
request->setRawHeader("User-Agent", userAgent.toUtf8());
request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
- reply = WebServices::manager()->post(*request, qPrintable(QString(email + " " + password)));
+ reply = WebServices::manager()->post(*request, qPrintable(payload));
connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished()));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
@@ -955,8 +965,13 @@ void CloudStorageAuthenticate::uploadFinished()
{
QString cloudAuthReply(reply->readAll());
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
- prefs.show_cloud_pin = (cloudAuthReply == "[VERIFY]");
- emit finishedAuthenticate(prefs.show_cloud_pin);
+ if (cloudAuthReply == "[VERIFIED]") {
+ prefs.show_cloud_pin = false;
+ emit finishedAuthenticate(prefs.show_cloud_pin);
+ } else if (cloudAuthReply == "[VERIFY]") {
+ prefs.show_cloud_pin = true;
+ emit finishedAuthenticate(prefs.show_cloud_pin);
+ }
}
void CloudStorageAuthenticate::uploadError(QNetworkReply::NetworkError error)