diff options
author | Max <max@nextcloud.com> | 2023-08-09 09:33:07 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-08-17 21:49:28 +0000 |
commit | f32dccd54097d21e3fbf52a6bfd22fdb20201b65 (patch) | |
tree | 4aaa50ef032853aed86b396d9afb1472cef41d60 | |
parent | 362acd93aaffdb1271c8d5356cd2d6ea4ffaf9e1 (diff) | |
download | nextcloud-server-f32dccd54097d21e3fbf52a6bfd22fdb20201b65.tar.gz nextcloud-server-f32dccd54097d21e3fbf52a6bfd22fdb20201b65.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.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 8fc16d5ce1a..4e26bd46e9f 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -61,6 +61,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 Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -800,6 +801,10 @@ class AccountManager implements IAccountManager { return $this->internalCache->get($user->getUID()); } $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; } |