mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: check if credentials are valid before accepting them
It seems crazy to simply assume that the later code can successfully untangle the various states that the credentials can be in - let's just stay on the credentials enrty page until we have verified credentials. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d717b9d2a7
commit
f6f6a20555
1 changed files with 14 additions and 7 deletions
|
@ -457,9 +457,11 @@ void QMLManager::saveCloudCredentials()
|
||||||
{
|
{
|
||||||
QSettings s;
|
QSettings s;
|
||||||
bool cloudCredentialsChanged = false;
|
bool cloudCredentialsChanged = false;
|
||||||
|
bool noCloud = QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_NOCLOUD;
|
||||||
|
|
||||||
// make sure we only have letters, numbers, and +-_. in password and email address
|
// make sure we only have letters, numbers, and +-_. in password and email address
|
||||||
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
|
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
|
||||||
if (QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_NOCLOUD) {
|
if (!noCloud) {
|
||||||
// in case of NO_CLOUD, the email address + passwd do not care, so do not check it.
|
// in case of NO_CLOUD, the email address + passwd do not care, so do not check it.
|
||||||
if (QMLPrefs::instance()->cloudPassword().isEmpty() ||
|
if (QMLPrefs::instance()->cloudPassword().isEmpty() ||
|
||||||
!regExp.match(QMLPrefs::instance()->cloudPassword()).hasMatch() ||
|
!regExp.match(QMLPrefs::instance()->cloudPassword()).hasMatch() ||
|
||||||
|
@ -474,11 +476,6 @@ void QMLManager::saveCloudCredentials()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.beginGroup("CloudStorage");
|
|
||||||
s.setValue("email", QMLPrefs::instance()->cloudUserName());
|
|
||||||
s.setValue("password", QMLPrefs::instance()->cloudPassword());
|
|
||||||
s.setValue("cloud_verification_status", QMLPrefs::instance()->credentialStatus());
|
|
||||||
s.sync();
|
|
||||||
if (!same_string(prefs.cloud_storage_email,
|
if (!same_string(prefs.cloud_storage_email,
|
||||||
qPrintable(QMLPrefs::instance()->cloudUserName()))) {
|
qPrintable(QMLPrefs::instance()->cloudUserName()))) {
|
||||||
free((void *)prefs.cloud_storage_email);
|
free((void *)prefs.cloud_storage_email);
|
||||||
|
@ -495,12 +492,22 @@ void QMLManager::saveCloudCredentials()
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
|
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!noCloud &&
|
||||||
|
!verifyCredentials(QMLPrefs::instance()->cloudUserName(), QMLPrefs::instance()->cloudPassword(), QMLPrefs::instance()->cloudPin()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
s.beginGroup("CloudStorage");
|
||||||
|
s.setValue("email", QMLPrefs::instance()->cloudUserName());
|
||||||
|
s.setValue("password", QMLPrefs::instance()->cloudPassword());
|
||||||
|
s.setValue("cloud_verification_status", QMLPrefs::instance()->credentialStatus());
|
||||||
|
s.sync();
|
||||||
|
|
||||||
if (!same_string(prefs.cloud_storage_password,
|
if (!same_string(prefs.cloud_storage_password,
|
||||||
qPrintable(QMLPrefs::instance()->cloudPassword()))) {
|
qPrintable(QMLPrefs::instance()->cloudPassword()))) {
|
||||||
free((void *)prefs.cloud_storage_password);
|
free((void *)prefs.cloud_storage_password);
|
||||||
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
||||||
}
|
}
|
||||||
if (QMLPrefs::instance()->oldStatus() == qPrefCloudStorage::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
|
if (noCloud && cloudCredentialsChanged && dive_table.nr) {
|
||||||
// we came from NOCLOUD and are connecting to a cloud account;
|
// we came from NOCLOUD and are connecting to a cloud account;
|
||||||
// since we already have dives in the table, let's remember that so we can keep them
|
// since we already have dives in the table, let's remember that so we can keep them
|
||||||
noCloudToCloud = true;
|
noCloudToCloud = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue