diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-09-10 06:49:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-10 16:26:49 -0700 |
commit | 2b3f6c607bf5eb7c6b24160832ba83ed60dca543 (patch) | |
tree | ba38e074a9fbad112dab25616a804e17e7b248ff | |
parent | ae653703a5d3ff1da84053d4542420fc70325c5f (diff) | |
download | subsurface-2b3f6c607bf5eb7c6b24160832ba83ed60dca543.tar.gz |
prefs: cloud_new_password is not a preference
It's a mamber of the cloud storage authentication class, used to hold the
proposed new password until the backend has accepted it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/cloudstorage.cpp | 5 | ||||
-rw-r--r-- | core/cloudstorage.h | 1 | ||||
-rw-r--r-- | core/pref.h | 1 | ||||
-rw-r--r-- | core/settings/qPrefCloudStorage.cpp | 11 | ||||
-rw-r--r-- | core/settings/qPrefCloudStorage.h | 5 | ||||
-rw-r--r-- | core/subsurfacestartup.c | 1 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_network.cpp | 1 | ||||
-rw-r--r-- | tests/testqPrefCloudStorage.cpp | 20 | ||||
-rw-r--r-- | tests/tst_qPrefCloudStorage.qml | 4 |
9 files changed, 4 insertions, 45 deletions
diff --git a/core/cloudstorage.cpp b/core/cloudstorage.cpp index 51bdf5994..24a536992 100644 --- a/core/cloudstorage.cpp +++ b/core/cloudstorage.cpp @@ -26,6 +26,7 @@ QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QStr } else if (!newpasswd.isEmpty()) { requestUrl = QUrl(CLOUDBACKENDUPDATE); payload += QChar(' ') + newpasswd; + cloudNewPassword = newpasswd; } else { requestUrl = QUrl(CLOUDBACKENDVERIFY); payload += QChar(' ') + pin; @@ -64,8 +65,8 @@ void CloudStorageAuthenticate::uploadFinished() report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences"))); } else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) { free((void *)prefs.cloud_storage_password); - prefs.cloud_storage_password = prefs.cloud_storage_newpassword; - prefs.cloud_storage_newpassword = NULL; + prefs.cloud_storage_password = strdup(qPrintable(cloudNewPassword)); + cloudNewPassword.clear(); emit passwordChangeSuccessful(); return; } else { diff --git a/core/cloudstorage.h b/core/cloudstorage.h index 5ce42a718..681b2b290 100644 --- a/core/cloudstorage.h +++ b/core/cloudstorage.h @@ -21,6 +21,7 @@ slots: private: QNetworkReply *reply; QString userAgent; + QString cloudNewPassword; }; QNetworkAccessManager *manager(); diff --git a/core/pref.h b/core/pref.h index f66a463cc..8b8feb449 100644 --- a/core/pref.h +++ b/core/pref.h @@ -91,7 +91,6 @@ struct preferences { const char *cloud_git_url; const char *cloud_storage_email; const char *cloud_storage_email_encoded; - const char *cloud_storage_newpassword; const char *cloud_storage_password; const char *cloud_storage_pin; short cloud_timeout; diff --git a/core/settings/qPrefCloudStorage.cpp b/core/settings/qPrefCloudStorage.cpp index 4576de6fb..ff9ad2553 100644 --- a/core/settings/qPrefCloudStorage.cpp +++ b/core/settings/qPrefCloudStorage.cpp @@ -56,17 +56,6 @@ HANDLE_PREFERENCE_TXT(CloudStorage, "email", cloud_storage_email); HANDLE_PREFERENCE_TXT(CloudStorage, "email_encoded", cloud_storage_email_encoded); -void qPrefCloudStorage::set_cloud_storage_newpassword(const QString &value) -{ - if (value == prefs.cloud_storage_newpassword) - return; - - qPrefPrivate::copy_txt(&prefs.cloud_storage_newpassword, value); - - // NOT saved on disk, because it is only temporary - emit instance()->cloud_storage_newpassword_changed(value); -} - void qPrefCloudStorage::set_cloud_storage_password(const QString &value) { if (value != prefs.cloud_storage_password) { diff --git a/core/settings/qPrefCloudStorage.h b/core/settings/qPrefCloudStorage.h index f9a08372f..751b67675 100644 --- a/core/settings/qPrefCloudStorage.h +++ b/core/settings/qPrefCloudStorage.h @@ -11,7 +11,6 @@ class qPrefCloudStorage : public QObject { Q_PROPERTY(QString cloud_git_url READ cloud_git_url); Q_PROPERTY(QString cloud_storage_email READ cloud_storage_email WRITE set_cloud_storage_email NOTIFY cloud_storage_email_changed); Q_PROPERTY(QString cloud_storage_email_encoded READ cloud_storage_email_encoded WRITE set_cloud_storage_email_encoded NOTIFY cloud_storage_email_encoded_changed); - Q_PROPERTY(QString cloud_storage_newpassword READ cloud_storage_newpassword WRITE set_cloud_storage_newpassword NOTIFY cloud_storage_newpassword_changed); Q_PROPERTY(QString cloud_storage_password READ cloud_storage_password WRITE set_cloud_storage_password NOTIFY cloud_storage_password_changed); Q_PROPERTY(QString cloud_storage_pin READ cloud_storage_pin WRITE set_cloud_storage_pin NOTIFY cloud_storage_pin_changed); Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_status_changed); @@ -34,7 +33,6 @@ public: static QString cloud_git_url() { return prefs.cloud_git_url; } static QString cloud_storage_email() { return prefs.cloud_storage_email; } static QString cloud_storage_email_encoded() { return prefs.cloud_storage_email_encoded; } - static QString cloud_storage_newpassword() { return prefs.cloud_storage_newpassword; } static QString cloud_storage_password() { return prefs.cloud_storage_password; } static QString cloud_storage_pin() { return prefs.cloud_storage_pin; } static int cloud_timeout() { return prefs.cloud_timeout; } @@ -47,7 +45,6 @@ public slots: static void set_cloud_base_url(const QString &value); static void set_cloud_storage_email(const QString &value); static void set_cloud_storage_email_encoded(const QString &value); - static void set_cloud_storage_newpassword(const QString &value); static void set_cloud_storage_password(const QString &value); static void set_cloud_storage_pin(const QString &value); static void set_cloud_timeout(int value); @@ -60,7 +57,6 @@ signals: void cloud_base_url_changed(const QString &value); void cloud_storage_email_changed(const QString &value); void cloud_storage_email_encoded_changed(const QString &value); - void cloud_storage_newpassword_changed(const QString &value); void cloud_storage_password_changed(const QString &value); void cloud_storage_pin_changed(const QString &value); void cloud_timeout_changed(int value); @@ -74,7 +70,6 @@ private: static void disk_cloud_base_url(bool doSync); static void disk_cloud_storage_email(bool doSync); static void disk_cloud_storage_email_encoded(bool doSync); - static void disk_cloud_storage_newpassword(bool doSync); static void disk_cloud_storage_password(bool doSync); static void disk_cloud_storage_pin(bool doSync); static void disk_cloud_timeout(bool doSync); diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c index 7e7ba0c9e..6e52b5156 100644 --- a/core/subsurfacestartup.c +++ b/core/subsurfacestartup.c @@ -307,7 +307,6 @@ void copy_prefs(struct preferences *src, struct preferences *dest) dest->date_format = copy_string(src->date_format); dest->date_format_short = copy_string(src->date_format_short); dest->cloud_storage_password = copy_string(src->cloud_storage_password); - dest->cloud_storage_newpassword = copy_string(src->cloud_storage_newpassword); dest->cloud_storage_email = copy_string(src->cloud_storage_email); dest->cloud_storage_email_encoded = copy_string(src->cloud_storage_email_encoded); dest->facebook.access_token = copy_string(src->facebook.access_token); diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp index 67b28c8f1..098bb9be8 100644 --- a/desktop-widgets/preferences/preferences_network.cpp +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -76,7 +76,6 @@ void PreferencesNetwork::syncSettings() connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful); cloudAuth->backend(email, password, "", newpassword); ui->cloud_storage_new_passwd->setText(""); - cloud->set_cloud_storage_newpassword(newpassword); } } else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN || prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD || diff --git a/tests/testqPrefCloudStorage.cpp b/tests/testqPrefCloudStorage.cpp index 9d726ab47..ab52312d6 100644 --- a/tests/testqPrefCloudStorage.cpp +++ b/tests/testqPrefCloudStorage.cpp @@ -24,7 +24,6 @@ void TestQPrefCloudStorage::test_struct_get() prefs.cloud_git_url = copy_qstring("new again url"); prefs.cloud_storage_email = copy_qstring("myEmail"); prefs.cloud_storage_email_encoded = copy_qstring("encodedMyEMail"); - prefs.cloud_storage_newpassword = copy_qstring("secret"); prefs.cloud_storage_password = copy_qstring("more secret"); prefs.cloud_storage_pin = copy_qstring("a pin"); prefs.cloud_timeout = 117; @@ -37,7 +36,6 @@ void TestQPrefCloudStorage::test_struct_get() QCOMPARE(tst->cloud_git_url(), QString(prefs.cloud_git_url)); QCOMPARE(tst->cloud_storage_email(), QString(prefs.cloud_storage_email)); QCOMPARE(tst->cloud_storage_email_encoded(), QString(prefs.cloud_storage_email_encoded)); - QCOMPARE(tst->cloud_storage_newpassword(), QString(prefs.cloud_storage_newpassword)); QCOMPARE(tst->cloud_storage_password(), QString(prefs.cloud_storage_password)); QCOMPARE(tst->cloud_storage_pin(), QString(prefs.cloud_storage_pin)); QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout); @@ -56,7 +54,6 @@ void TestQPrefCloudStorage::test_set_struct() tst->set_cloud_base_url("t2 base"); tst->set_cloud_storage_email("t2 email"); tst->set_cloud_storage_email_encoded("t2 email2"); - tst->set_cloud_storage_newpassword("t2 pass1"); tst->set_cloud_storage_password("t2 pass2"); tst->set_cloud_storage_pin("t2 pin"); tst->set_cloud_timeout(123); @@ -68,7 +65,6 @@ void TestQPrefCloudStorage::test_set_struct() QCOMPARE(QString(prefs.cloud_base_url), QString("t2 base")); QCOMPARE(QString(prefs.cloud_storage_email), QString("t2 email")); QCOMPARE(QString(prefs.cloud_storage_email_encoded), QString("t2 email2")); - QCOMPARE(QString(prefs.cloud_storage_newpassword), QString("t2 pass1")); QCOMPARE(QString(prefs.cloud_storage_password), QString("t2 pass2")); QCOMPARE(QString(prefs.cloud_storage_pin), QString("t2 pin")); QCOMPARE((int)prefs.cloud_timeout, 123); @@ -90,7 +86,6 @@ void TestQPrefCloudStorage::test_set_load_struct() tst->set_cloud_base_url("t3 base"); tst->set_cloud_storage_email("t3 email"); tst->set_cloud_storage_email_encoded("t3 email2"); - tst->set_cloud_storage_newpassword("t3 pass1"); tst->set_save_password_local(true); tst->set_cloud_storage_password("t3 pass2"); tst->set_cloud_storage_pin("t3 pin"); @@ -103,7 +98,6 @@ void TestQPrefCloudStorage::test_set_load_struct() prefs.cloud_git_url = copy_qstring("error1"); prefs.cloud_storage_email = copy_qstring("error1"); prefs.cloud_storage_email_encoded = copy_qstring("error1"); - prefs.cloud_storage_newpassword = copy_qstring("my new password"); prefs.cloud_storage_password = copy_qstring("error1"); prefs.cloud_storage_pin = copy_qstring("error1"); prefs.cloud_timeout = 324; @@ -126,9 +120,6 @@ void TestQPrefCloudStorage::test_set_load_struct() // remark is set with set_base_url QCOMPARE(QString(prefs.cloud_git_url), QString("t3 base/git")); - - // warning new password is not saved on disk - QCOMPARE(QString(prefs.cloud_storage_newpassword), QString("my new password")); } void TestQPrefCloudStorage::test_struct_disk() @@ -140,7 +131,6 @@ void TestQPrefCloudStorage::test_struct_disk() prefs.cloud_base_url = copy_qstring("t4 base"); prefs.cloud_storage_email = copy_qstring("t4 email"); prefs.cloud_storage_email_encoded = copy_qstring("t4 email2"); - prefs.cloud_storage_newpassword = copy_qstring("t4 pass1"); prefs.save_password_local = true; prefs.cloud_storage_password = copy_qstring("t4 pass2"); prefs.cloud_storage_pin = copy_qstring("t4 pin"); @@ -155,7 +145,6 @@ void TestQPrefCloudStorage::test_struct_disk() prefs.cloud_git_url = copy_qstring("error1"); prefs.cloud_storage_email = copy_qstring("error1"); prefs.cloud_storage_email_encoded = copy_qstring("error1"); - prefs.cloud_storage_newpassword = copy_qstring("my new password"); prefs.cloud_storage_password = copy_qstring("error1"); prefs.cloud_storage_pin = copy_qstring("error1"); prefs.cloud_timeout = 324; @@ -179,9 +168,6 @@ void TestQPrefCloudStorage::test_struct_disk() // remark is set with set_base_url QCOMPARE(QString(prefs.cloud_git_url), QString("t4 base/git")); - - // warning new password not stored on disk - QCOMPARE(QString(prefs.cloud_storage_newpassword), QString("my new password")); } void TestQPrefCloudStorage::test_multiple() @@ -219,12 +205,6 @@ void TestQPrefCloudStorage::test_oldPreferences() cloud->set_cloud_storage_email("tomaz@gmail.com"); TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com")); - // Why there's new password and password on the prefs? - cloud->set_cloud_storage_newpassword("ABCD"); - TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD")); - cloud->set_cloud_storage_newpassword("ABCDE"); - TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCDE")); - cloud->set_cloud_storage_password("ABCDE"); TEST(cloud->cloud_storage_password(), QStringLiteral("ABCDE")); cloud->set_cloud_storage_password("ABCABC"); diff --git a/tests/tst_qPrefCloudStorage.qml b/tests/tst_qPrefCloudStorage.qml index 0d0dc6b61..5e62b96a4 100644 --- a/tests/tst_qPrefCloudStorage.qml +++ b/tests/tst_qPrefCloudStorage.qml @@ -30,10 +30,6 @@ TestCase { tst.cloud_storage_email_encoded= "my email enc" compare(tst.cloud_storage_email_encoded, "my email enc") - var x5 = tst.cloud_storage_newpassword - tst.cloud_storage_newpassword = "my new password" - compare(tst.cloud_storage_newpassword, "my new password") - var x6 = tst.cloud_storage_password tst.cloud_storage_password = "my url" compare(tst.cloud_storage_password, "my url") |