[trojita] src/Gui: GUI: Do not keep reusing wrong password

Jan Kundrát null at kde.org
Mon Feb 13 00:07:22 UTC 2017


Git commit 430d6802f44e7262005c1d6413b290bd383c57f0 by Jan Kundrát.
Committed on 02/02/2017 at 20:13.
Pushed by gerrit into branch 'master'.

GUI: Do not keep reusing wrong password

Since commit 76648e4248, Trojitá has started forgetting to forget a
cached password which proved to be wrong. When a password was provided
by some plugin, the UI would never ask the user for one after a login
failure. That's suboptimal, especially considering that the code would
just happily loop and issue many login requests using the same
credentials over and over again.

Thanks to Marc Lambrecht (whytrytofly on IRC) for reporting this.

Change-Id: I1920176ad71910bea6e8c83033e444dc01c076bf
BUG: 375822

M  +8    -0    src/Gui/Window.cpp

https://commits.kde.org/trojita/430d6802f44e7262005c1d6413b290bd383c57f0

diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 8ad9b718..996c0c4f 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -839,10 +839,18 @@ void MainWindow::setupModels()
     connect(imapModel(), &Imap::Mailbox::Model::imapError, this, &MainWindow::imapError);
     connect(imapModel(), &Imap::Mailbox::Model::networkError, this, &MainWindow::networkError);
     connect(imapModel(), &Imap::Mailbox::Model::authRequested, this, &MainWindow::authenticationRequested, Qt::QueuedConnection);
+    connect(imapModel(), &Imap::Mailbox::Model::authAttemptFailed, this, [this]() {
+        m_ignoreStoredPassword = true;
+    });
 
     connect(imapModel(), &Imap::Mailbox::Model::networkPolicyOffline, this, &MainWindow::networkPolicyOffline);
     connect(imapModel(), &Imap::Mailbox::Model::networkPolicyExpensive, this, &MainWindow::networkPolicyExpensive);
     connect(imapModel(), &Imap::Mailbox::Model::networkPolicyOnline, this, &MainWindow::networkPolicyOnline);
+    connect(imapModel(), &Imap::Mailbox::Model::connectionStateChanged, this, [this](uint, const Imap::ConnectionState state) {
+        if (state == Imap::CONN_STATE_AUTHENTICATED) {
+            m_ignoreStoredPassword = false;
+        }
+    });
     connect(imapModel(), &Imap::Mailbox::Model::connectionStateChanged, this, &MainWindow::showConnectionStatus);
 
     connect(imapModel(), &Imap::Mailbox::Model::mailboxDeletionFailed, this, &MainWindow::slotMailboxDeleteFailed);



More information about the kde-doc-english mailing list