1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Automatically fill proxy credentials in proxyAuthorizationRequested

Also don't allow to save credentials into AutoFill. Proxy credentials
should be saved in Preferences.
This commit is contained in:
David Rosca 2015-10-15 15:38:44 +02:00
parent 0845606cc7
commit 34eac0d9db

View File

@ -148,6 +148,7 @@ void NetworkManager::authentication(const QUrl &url, QAuthenticator *auth, QWidg
} }
if (dialog->exec() != QDialog::Accepted) { if (dialog->exec() != QDialog::Accepted) {
delete dialog;
return; return;
} }
@ -164,14 +165,16 @@ void NetworkManager::authentication(const QUrl &url, QAuthenticator *auth, QWidg
fill->addEntry(url, user->text(), pass->text()); fill->addEntry(url, user->text(), pass->text());
} }
} }
delete dialog;
} }
void NetworkManager::proxyAuthentication(const QString &proxyHost, QAuthenticator *auth, QWidget *parent) void NetworkManager::proxyAuthentication(const QString &proxyHost, QAuthenticator *auth, QWidget *parent)
{ {
QVector<PasswordEntry> passwords = mApp->autoFill()->getFormData(QUrl(proxyHost)); const QNetworkProxy proxy = QNetworkProxy::applicationProxy();
if (!passwords.isEmpty()) { if (!proxy.user().isEmpty() && !proxy.password().isEmpty()) {
auth->setUser(passwords.at(0).username); auth->setUser(proxy.user());
auth->setPassword(passwords.at(0).password); auth->setPassword(proxy.password());
return; return;
} }
@ -189,8 +192,6 @@ void NetworkManager::proxyAuthentication(const QString &proxyHost, QAuthenticato
QLineEdit* user = new QLineEdit(dialog); QLineEdit* user = new QLineEdit(dialog);
QLineEdit* pass = new QLineEdit(dialog); QLineEdit* pass = new QLineEdit(dialog);
pass->setEchoMode(QLineEdit::Password); pass->setEchoMode(QLineEdit::Password);
QCheckBox* save = new QCheckBox(dialog);
save->setText(tr("Remember username and password for this proxy."));
QDialogButtonBox* box = new QDialogButtonBox(dialog); QDialogButtonBox* box = new QDialogButtonBox(dialog);
box->addButton(QDialogButtonBox::Ok); box->addButton(QDialogButtonBox::Ok);
@ -202,19 +203,17 @@ void NetworkManager::proxyAuthentication(const QString &proxyHost, QAuthenticato
formLa->addRow(label); formLa->addRow(label);
formLa->addRow(userLab, user); formLa->addRow(userLab, user);
formLa->addRow(passLab, pass); formLa->addRow(passLab, pass);
formLa->addRow(save);
formLa->addWidget(box); formLa->addWidget(box);
if (dialog->exec() != QDialog::Accepted) { if (dialog->exec() != QDialog::Accepted) {
delete dialog;
return; return;
} }
if (save->isChecked()) {
mApp->autoFill()->addEntry(QUrl(proxyHost), user->text(), pass->text());
}
auth->setUser(user->text()); auth->setUser(user->text());
auth->setPassword(pass->text()); auth->setPassword(pass->text());
delete dialog;
} }
void NetworkManager::installUrlInterceptor(UrlInterceptor *interceptor) void NetworkManager::installUrlInterceptor(UrlInterceptor *interceptor)