Commit c9ae1636 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

[IMAP] Fix migration to new Gmail authentication

Currently the settings would be migrated only if user opened the
Settings dialog. The GmailPasswordRequester expects that the server
settings is migrated correctly and always tries to authenticate via
XOAUTH2, even if the configuration says "PLAIN" or other mechanism.
This breaks login as we try to send XOAUTH2 tokens as PLAIN credentials.

This change ensures that the encryption and auth mechanism settings
is correctly migrated on resource startup.

CCBUG: 378857
CCBUG: 378876
parent b5890530
......@@ -23,6 +23,7 @@
#include "imapaccount.h"
#include "utils.h"
#include "config.h"
#include <kwallet.h>
using KWallet::Wallet;
......@@ -78,6 +79,17 @@ Settings::Settings(WId winId) : SettingsBase(), m_winId(winId)
{
load();
#ifdef WITH_GMAIL_XOAUTH2
// Make sure that Gmail configuration is correctly migrated even if the user
// did not open the configuration dialog
if (Utils::isGmail(imapServer())) {
setImapPort(993);
setSafety(QStringLiteral("SSL"));
setAuthentication(MailTransport::Transport::EnumAuthenticationType::XOAUTH2);
save();
}
#endif
new SettingsAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"), this, QDBusConnection::ExportAdaptors | QDBusConnection::ExportScriptableContents);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment