summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-16 13:30:02 +0100
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-18 09:44:08 +0100
commitd28f48a793aef1e1c07a28758c97f399f8c0a93b (patch)
tree711d27908b4a0046d10f4a0ef2a41a20a29fe28a
parentff9bdfd0dfa22493d6721a072d0923bf7c175434 (diff)
downloadsubsurface-d28f48a793aef1e1c07a28758c97f399f8c0a93b.tar.gz
Fix preferences handling with invalid passwords
This fixes 2 problems related to entering passwords with illegal characters in it: 1) Do not save an invalid password in the preferences, but keep the old one. 2) On password change, check both old and new password for format validity instead of pushing an invalid password to the server that has to ignore it. Fixes: #1048 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp
index a8cbbd70b..252694037 100644
--- a/desktop-widgets/preferences/preferences_network.cpp
+++ b/desktop-widgets/preferences/preferences_network.cpp
@@ -69,7 +69,12 @@ void PreferencesNetwork::syncSettings()
// connect to backend server to check / create credentials
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
- report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ report_error(qPrintable(tr("Change ignored. Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ return;
+ } else if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) {
+ report_error(qPrintable(tr("Change ignored. Cloud storage email and new password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ ui->cloud_storage_new_passwd->setText("");
+ return;
} else {
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
@@ -85,12 +90,15 @@ void PreferencesNetwork::syncSettings()
password != prefs.cloud_storage_password) {
// different credentials - reset verification status
+ int oldVerificationStatus = cloud->verificationStatus();
cloud->setVerificationStatus(CS_UNKNOWN);
if (!email.isEmpty() && !password.isEmpty()) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ cloud->setVerificationStatus(oldVerificationStatus);
+ return;
} else {
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
@@ -104,6 +112,7 @@ void PreferencesNetwork::syncSettings()
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 '+'.")));
+ return;
}
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(updateCloudAuthenticationState()));