mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
Make password change asynchronous
This isn't perfect (if you make multiple requests things could go badly), but it's better than just slapping the new password into the settings, even if the update failed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
aa9c2b7384
commit
9a68e356af
5 changed files with 17 additions and 2 deletions
1
pref.h
1
pref.h
|
@ -109,6 +109,7 @@ struct preferences {
|
||||||
short default_file_behavior;
|
short default_file_behavior;
|
||||||
facebook_prefs_t facebook;
|
facebook_prefs_t facebook;
|
||||||
char *cloud_storage_password;
|
char *cloud_storage_password;
|
||||||
|
char *cloud_storage_newpassword;
|
||||||
char *cloud_storage_email;
|
char *cloud_storage_email;
|
||||||
char *cloud_storage_email_encoded;
|
char *cloud_storage_email_encoded;
|
||||||
bool save_password_local;
|
bool save_password_local;
|
||||||
|
|
|
@ -423,10 +423,11 @@ void PreferencesDialog::syncSettings()
|
||||||
} else {
|
} else {
|
||||||
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
||||||
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
|
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
|
||||||
|
connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull()));
|
||||||
QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword);
|
QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword);
|
||||||
ui.cloud_storage_new_passwd->setText("");
|
ui.cloud_storage_new_passwd->setText("");
|
||||||
ui.cloud_storage_password->setText(newpassword);
|
free(prefs.cloud_storage_newpassword);
|
||||||
password = newpassword;
|
prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (prefs.cloud_verification_status == CS_UNKNOWN ||
|
} else if (prefs.cloud_verification_status == CS_UNKNOWN ||
|
||||||
|
@ -688,6 +689,11 @@ void PreferencesDialog::on_resetSettings_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::passwordUpdateSuccessfull()
|
||||||
|
{
|
||||||
|
ui.cloud_storage_password->setText(prefs.cloud_storage_password);
|
||||||
|
}
|
||||||
|
|
||||||
void PreferencesDialog::emitSettingsChanged()
|
void PreferencesDialog::emitSettingsChanged()
|
||||||
{
|
{
|
||||||
emit settingsChanged();
|
emit settingsChanged();
|
||||||
|
|
|
@ -40,6 +40,7 @@ slots:
|
||||||
void facebookLoggedIn();
|
void facebookLoggedIn();
|
||||||
void facebookDisconnect();
|
void facebookDisconnect();
|
||||||
void cloudPinNeeded();
|
void cloudPinNeeded();
|
||||||
|
void passwordUpdateSuccessfull();
|
||||||
private:
|
private:
|
||||||
explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
void setUiFromPrefs();
|
void setUiFromPrefs();
|
||||||
|
|
|
@ -1029,6 +1029,12 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
myLastError.clear();
|
myLastError.clear();
|
||||||
} else if (cloudAuthReply == "[VERIFY]") {
|
} else if (cloudAuthReply == "[VERIFY]") {
|
||||||
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
|
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
|
||||||
|
} else if (cloudAuthReply == "[PASSWDCHANGED]") {
|
||||||
|
free(prefs.cloud_storage_password);
|
||||||
|
prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
|
||||||
|
prefs.cloud_storage_newpassword = NULL;
|
||||||
|
emit passwordChangeSuccessful();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
prefs.cloud_verification_status = CS_INCORRECT_USER_PASSWD;
|
prefs.cloud_verification_status = CS_INCORRECT_USER_PASSWD;
|
||||||
myLastError = cloudAuthReply;
|
myLastError = cloudAuthReply;
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
explicit CloudStorageAuthenticate(QObject *parent);
|
explicit CloudStorageAuthenticate(QObject *parent);
|
||||||
signals:
|
signals:
|
||||||
void finishedAuthenticate();
|
void finishedAuthenticate();
|
||||||
|
void passwordChangeSuccessful();
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void uploadError(QNetworkReply::NetworkError error);
|
void uploadError(QNetworkReply::NetworkError error);
|
||||||
|
|
Loading…
Reference in a new issue