mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Avoid re-entrency in HTTPCredidential::fetch
It is likely to re-enter if there is two jobs that asks for a password. Example: 1. log out 2. restart the application 3. enter a wrong password 4. enter a wrong password again a few times 5. enter the correct password 6. it should must not prompt for the password again. Because of the re-entrency, it was still prompting for the password several times after the right password had been entered
This commit is contained in:
parent
05a1f7b1bb
commit
e468ea2d68
@ -100,7 +100,8 @@ HttpCredentials::HttpCredentials()
|
||||
HttpCredentials::HttpCredentials(const QString& user, const QString& password)
|
||||
: _user(user),
|
||||
_password(password),
|
||||
_ready(true)
|
||||
_ready(true),
|
||||
_fetchJobInProgress(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -183,6 +184,10 @@ void HttpCredentials::fetch(Account *account)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_fetchJobInProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchUser(account);
|
||||
|
||||
QSettings *settings = account->settingsWithGroup(Theme::instance()->appName());
|
||||
@ -207,6 +212,7 @@ void HttpCredentials::fetch(Account *account)
|
||||
connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
|
||||
job->setProperty("account", QVariant::fromValue(account));
|
||||
job->start();
|
||||
_fetchJobInProgress = true;
|
||||
}
|
||||
}
|
||||
bool HttpCredentials::stillValid(QNetworkReply *reply)
|
||||
@ -234,6 +240,7 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
|
||||
// Still, the password can be empty which indicates a problem and
|
||||
// the password dialog has to be opened.
|
||||
_ready = true;
|
||||
_fetchJobInProgress = false;
|
||||
emit fetched();
|
||||
} else {
|
||||
if( error != NoError ) {
|
||||
@ -241,6 +248,7 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
|
||||
}
|
||||
bool ok;
|
||||
QString pwd = queryPassword(&ok);
|
||||
_fetchJobInProgress = false;
|
||||
if (ok) {
|
||||
_password = pwd;
|
||||
_ready = true;
|
||||
|
||||
@ -62,6 +62,7 @@ private:
|
||||
QString _user;
|
||||
QString _password;
|
||||
bool _ready;
|
||||
bool _fetchJobInProgress; //True if the keychain job is in progress or the input dialog visible
|
||||
};
|
||||
|
||||
} // ns Mirall
|
||||
|
||||
Loading…
Reference in New Issue
Block a user