aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <max@nextcloud.com>2023-08-09 09:33:07 +0200
committermax-nextcloud <max@nextcloud.com>2023-08-15 14:55:03 +0200
commit99a4a9cd09abe78a9a0b35e6c7ede472b80fdbf9 (patch)
tree5b12cc430f6a19e7a7e7a40bf00cd18adab68e30
parent240e8ab0997d93c63dcbe792bc06fdf29bc60b57 (diff)
downloadnextcloud-server-99a4a9cd09abe78a9a0b35e6c7ede472b80fdbf9.tar.gz
nextcloud-server-99a4a9cd09abe78a9a0b35e6c7ede472b80fdbf9.zip
fix: always use display name from correct backend
Overwrite the display name after the account is initialized when using an instacne of IGetDisplayNameBackend. Before when using a variation of user_oidc and registering a Backend.php implementing IGetDisplayNameBackend the personal setting page shows 'uid'. The UserManager/AccountManager seems not to use consistently the correct backend. The correct backend is used in this sequence: server/lib/private/TemplateLayout.php $userDisplayName = \OC_User::getDisplayName(); $this->assign(user_displayname, $userDisplayName); In the settings page, it definitely not calls the registered backend, but seems to fall back to default Backend and shows (usually) uid or a value from the standard account property table. Signed-off-by: Max <max@nextcloud.com>
-rw-r--r--lib/private/Accounts/AccountManager.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 95199d8380c..9865438161b 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -62,6 +62,7 @@ use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Security\ICrypto;
use OCP\Security\VerificationToken\IVerificationToken;
+use OCP\User\Backend\IGetDisplayNameBackend;
use OCP\Util;
use Psr\Log\LoggerInterface;
use function array_flip;
@@ -744,6 +745,10 @@ class AccountManager implements IAccountManager {
return $cached;
}
$account = $this->parseAccountData($user, $this->getUser($user));
+ if ($user->getBackend() instanceof IGetDisplayNameBackend) {
+ $property = $account->getProperty(self::PROPERTY_DISPLAYNAME);
+ $account->setProperty(self::PROPERTY_DISPLAYNAME, $user->getDisplayName(), $property->getScope(), $property->getVerified());
+ }
$this->internalCache->set($user->getUID(), $account);
return $account;
}