Skip to content

Commit

Permalink
fix: always use display name from correct backend
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
max-nextcloud committed Aug 9, 2023
1 parent 5fcb19c commit cbc436e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/private/Accounts/AccountManager.php
Expand Up @@ -41,6 +41,7 @@
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use OC\Profile\TProfileHelper;
use OC\User\Backend;
use OCP\Accounts\UserUpdatedEvent;
use OCP\Cache\CappedMemoryCache;
use OCA\Settings\BackgroundJobs\VerifyUserData;
Expand All @@ -62,6 +63,7 @@
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;
Expand Down Expand Up @@ -744,6 +746,9 @@ public function getAccount(IUser $user): IAccount {
return $cached;
}
$account = $this->parseAccountData($user, $this->getUser($user));
if ($user->getBackend() instanceof IGetDisplayNameBackend) {
$account->setProperty(self::PROPERTY_DISPLAYNAME, $user->getDisplayName());

Check failure on line 750 in lib/private/Accounts/AccountManager.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TooFewArguments

lib/private/Accounts/AccountManager.php:750:14: TooFewArguments: Too few arguments for OC\Accounts\Account::setProperty - expecting scope to be passed (see https://psalm.dev/025)

Check failure on line 750 in lib/private/Accounts/AccountManager.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TooFewArguments

lib/private/Accounts/AccountManager.php:750:14: TooFewArguments: Too few arguments for OC\Accounts\Account::setProperty - expecting verified to be passed (see https://psalm.dev/025)

Check failure on line 750 in lib/private/Accounts/AccountManager.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TooFewArguments

lib/private/Accounts/AccountManager.php:750:14: TooFewArguments: Too few arguments for method OC\Accounts\Account::setproperty saw 2 (see https://psalm.dev/025)

Check failure

Code scanning / Psalm

TooFewArguments Error

Too few arguments for OC\Accounts\Account::setProperty - expecting scope to be passed

Check failure

Code scanning / Psalm

TooFewArguments Error

Too few arguments for OC\Accounts\Account::setProperty - expecting verified to be passed

Check failure

Code scanning / Psalm

TooFewArguments Error

Too few arguments for method OC\Accounts\Account::setproperty saw 2
}
$this->internalCache->set($user->getUID(), $account);
return $account;
}
Expand Down

0 comments on commit cbc436e

Please sign in to comment.