From 318bf5cccc9a8ac2c8ee18939e3c6c4a4e7a0fb3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 4 Jun 2015 17:26:30 -0700 Subject: Cloud storage: first stab at creating an account on the backend This triggers when the email address / password is changed in the preferences. It opens an https connection with the backend server (the URL is hardcoded) which should create an account with these credentials. Signed-off-by: Dirk Hohndel --- qt-ui/preferences.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'qt-ui/preferences.cpp') diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index f0f1212a2..8342dff78 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -9,6 +9,8 @@ #include #include +#include "subsurfacewebservices.h" + #if defined(FBSUPPORT) #include "socialnetworks.h" #endif @@ -360,10 +362,21 @@ void PreferencesDialog::syncSettings() s.endGroup(); s.beginGroup("CloudStorage"); - SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, ui.cloud_storage_email->text()); + QString email = ui.cloud_storage_email->text(); + QString password = ui.cloud_storage_password->text(); + if (email != prefs.cloud_storage_email || password != prefs.cloud_storage_password) { + // connect to backend server to check / create credentials + QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); + if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) { + report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + } + CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); + QNetworkReply *reply = cloudAuth->authenticate(email, password); + } + SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email); SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui.save_password_local->isChecked()); if (ui.save_password_local->isChecked()) - SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, ui.cloud_storage_password->text()); + SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password); else s.remove("password"); s.endGroup(); -- cgit v1.2.3-70-g09d2