mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Let the keychain return new creds during async save.
The credentials are asynchronously saved. The credentialstore now returns the creds even if the saving has not yet finished but is running, for that the new state AsyncWriting was added. That makes the start of the sync after the password was changed more reliable.
This commit is contained in:
parent
70f627ba06
commit
9dc21bf8a3
2 changed files with 14 additions and 15 deletions
|
@ -76,23 +76,14 @@ bool CredentialStore::canTryAgain()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( _state == NotFetched ) {
|
/* Since QtKeyChain is required now, it makes to only
|
||||||
|
* query once. */
|
||||||
|
if( _state == NotFetched || _state == AsyncWriting ) {
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( _type ) {
|
|
||||||
case CredentialStore::User:
|
|
||||||
canDoIt = true;
|
|
||||||
break;
|
|
||||||
case CredentialStore::Settings:
|
|
||||||
break;
|
|
||||||
case CredentialStore::KeyChain:
|
|
||||||
canDoIt = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return canDoIt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CredentialStore::fetchCredentials()
|
void CredentialStore::fetchCredentials()
|
||||||
|
@ -147,7 +138,7 @@ void CredentialStore::fetchCredentials()
|
||||||
}
|
}
|
||||||
case CredentialStore::KeyChain: {
|
case CredentialStore::KeyChain: {
|
||||||
// If the credentials are here already, return.
|
// If the credentials are here already, return.
|
||||||
if( _state == Ok ) {
|
if( _state == Ok || _state == AsyncWriting ) {
|
||||||
emit(fetchCredentialsFinished(true));
|
emit(fetchCredentialsFinished(true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -347,6 +338,7 @@ void CredentialStore::saveCredentials( )
|
||||||
|
|
||||||
connect( job, SIGNAL(finished(QKeychain::Job*)), this,
|
connect( job, SIGNAL(finished(QKeychain::Job*)), this,
|
||||||
SLOT(slotKeyChainWriteFinished(QKeychain::Job*)));
|
SLOT(slotKeyChainWriteFinished(QKeychain::Job*)));
|
||||||
|
_state = AsyncWriting;
|
||||||
job->start();
|
job->start();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -373,15 +365,21 @@ void CredentialStore::slotKeyChainWriteFinished( QKeychain::Job *job )
|
||||||
pwdJob->errorString().contains(QLatin1String("Could not open wallet"))) {
|
pwdJob->errorString().contains(QLatin1String("Could not open wallet"))) {
|
||||||
_type = Settings;
|
_type = Settings;
|
||||||
saveCredentials();
|
saveCredentials();
|
||||||
|
_state = NoKeychainBackend;
|
||||||
|
} else {
|
||||||
|
_state = Error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Successfully stored password for user " << _user;
|
qDebug() << "Successfully stored password for user " << _user;
|
||||||
// Try to remove password formerly stored in the config file.
|
// Try to remove password formerly stored in the config file.
|
||||||
MirallConfigFile cfgFile;
|
MirallConfigFile cfgFile;
|
||||||
cfgFile.clearPasswordFromConfig();
|
cfgFile.clearPasswordFromConfig();
|
||||||
|
_state = NotFetched;
|
||||||
|
_tries = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Error: KeyChain Write Password Job failed!";
|
qDebug() << "Error: KeyChain Write Password Job failed!";
|
||||||
|
_state = Error;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void) job;
|
(void) job;
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
AccessDenied,
|
AccessDenied,
|
||||||
NoKeychainBackend,
|
NoKeychainBackend,
|
||||||
Error,
|
Error,
|
||||||
|
AsyncWriting,
|
||||||
TooManyAttempts };
|
TooManyAttempts };
|
||||||
|
|
||||||
enum CredentialType {
|
enum CredentialType {
|
||||||
|
|
Loading…
Reference in a new issue