File Never-set-an-empty-name-when-creating-an-account.patch of Package kaccounts-integration

From 4600d32a1c063db62c371b422f26263d1e991b40 Mon Sep 17 00:00:00 2001
From: Wolfgang Bauer <wbauer@tmo.at>
Date: Mon, 2 Mar 2020 21:55:09 +0100
Subject: [PATCH] [CreateAccount job] Never set an empty name when creating an
 account

At least when creating a google account, signon-ui isn't able to extract
the username from the login page anymore since a couple of months (and
newer versions ported to QtWebEngine don't even extract it at all
anymore because it was considered to be too fragile, which apparently
proved to be true...).

This looks kind of broken, and actually made kio-gdrive useless as that
doesn't even list accounts with an empty name.

To fix it, set the name to some arbitrary string in the case that
info.userName() is empty.

BUG: 414219
FIXED-IN: 19.12.3
Differential Revision: https://phabricator.kde.org/D27474
---
 src/jobs/createaccount.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/jobs/createaccount.cpp b/src/jobs/createaccount.cpp
index 429bb62..d93efea 100644
--- a/src/jobs/createaccount.cpp
+++ b/src/jobs/createaccount.cpp
@@ -181,7 +181,12 @@ void CreateAccount::info(const SignOn::IdentityInfo &info)
     m_account->selectService();
 
     if (m_account->displayName().isEmpty()) {
-        m_account->setDisplayName(info.userName());
+        if(info.userName().isEmpty()) {
+            // info.userName() can be empty, see bug#414219
+            m_account->setDisplayName(QString("%1%2").arg(info.caption()).arg(info.id()));
+        } else {
+            m_account->setDisplayName(info.userName());
+        }
     }
     m_account->setValue("username", info.userName());
     m_account->setCredentialsId(info.id());
-- 
GitLab

openSUSE Build Service is sponsored by