Skip to content

Commit aa70929

Browse files
committed
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>
1 parent 850ca6a commit aa70929

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/private/Accounts/AccountManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
use OCP\Mail\IMailer;
6262
use OCP\Security\ICrypto;
6363
use OCP\Security\VerificationToken\IVerificationToken;
64+
use OCP\User\Backend\IGetDisplayNameBackend;
6465
use OCP\Util;
6566
use Psr\Log\LoggerInterface;
6667
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -800,6 +801,10 @@ public function getAccount(IUser $user): IAccount {
800801
return $this->internalCache->get($user->getUID());
801802
}
802803
$account = $this->parseAccountData($user, $this->getUser($user));
804+
if ($user->getBackend() instanceof IGetDisplayNameBackend) {
805+
$property = $account->getProperty(self::PROPERTY_DISPLAYNAME);
806+
$account->setProperty(self::PROPERTY_DISPLAYNAME, $user->getDisplayName(), $property->getScope(), $property->getVerified());
807+
}
803808
$this->internalCache->set($user->getUID(), $account);
804809
return $account;
805810
}

0 commit comments

Comments
 (0)