Skip to content

fix: always use display name from correct backend - #39770

Merged
max-nextcloud merged 1 commit into
masterfrom
fix/always-use-displayname-from-correct-backend
Aug 17, 2023
Merged

fix: always use display name from correct backend#39770
max-nextcloud merged 1 commit into
masterfrom
fix/always-use-displayname-from-correct-backend

Conversation

@max-nextcloud

Copy link
Copy Markdown
Contributor

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.

  • Resolves: #

Summary

TODO

  • ...

Checklist

@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from c3058b0 to cbc436eCompareAugust 9, 2023 07:36
Comment threadlib/private/Accounts/AccountManager.php Fixed
Comment threadlib/private/Accounts/AccountManager.php Fixed
Comment threadlib/private/Accounts/AccountManager.php Fixed
@juliusknorr

Copy link
Copy Markdown
Member

Looks sane, one thing I'll still want to double check is if this properly propagates to the system addressbook

@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from cbc436e to 136c804CompareAugust 9, 2023 14:36
}
$account = $this->parseAccountData($user, $this->getUser($user));
if ($user->getBackend() instanceof IGetDisplayNameBackend) {
$account->setProperty(self::PROPERTY_DISPLAYNAME, $user->getDisplayName());

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay... so this would need a scope and verified parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just take the existing scope/verified parameter from the account object obtained earlier i think

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now reuse the ones that were set on the original property from the account data as that mimics what the previous patch did.
I'm not sure that's what we want though. Given that we are getting the display name from the backend it's probably verified even if the display name in the original account data was not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not make any use of the verified parameter anyways for the displayname, the scope is user configured so it should be fine with this approach.

@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from 136c804 to b78d2fcCompareAugust 14, 2023 06:38
Comment threadlib/private/Accounts/AccountManager.php Fixed
Comment threadlib/private/Accounts/AccountManager.php Fixed
@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from b78d2fc to b72e979CompareAugust 14, 2023 06:45
@szaimenszaimen added the 3. to review Waiting for reviews label Aug 14, 2023
@szaimenszaimen added this to the Nextcloud 28 milestone Aug 14, 2023
@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from b72e979 to d3ce30cCompareAugust 14, 2023 07:35
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>
@max-nextcloud
max-nextcloudforce-pushed the fix/always-use-displayname-from-correct-backend branch from d3ce30c to 99a4a9cCompareAugust 15, 2023 12:55

@juliusknorrjuliusknorr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@juliusknorr

Copy link
Copy Markdown
Member

Asking @Pytal and @ChristophWurst for review as I think both worked with that accounts code in the past

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@max-nextcloud

Copy link
Copy Markdown
ContributorAuthor

/backport to stable27

@max-nextcloud

Copy link
Copy Markdown
ContributorAuthor

/backport to stable26

@max-nextcloud

Copy link
Copy Markdown
ContributorAuthor

/backport to stable25

@max-nextcloud
max-nextcloud merged commit 4b7aa65 into masterAug 17, 2023
@max-nextcloud
max-nextcloud deleted the fix/always-use-displayname-from-correct-backend branch August 17, 2023 21:10
@backportbot-nextcloud

Copy link
Copy Markdown

The backport to stable26 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable26
git pull origin stable26
# Create the new backport branch
git checkout -b fix/foo-stable26
# Cherry pick the change from the commit sha1 of the change against the default branch# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable26

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud

Copy link
Copy Markdown

The backport to stable25 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable25
git pull origin stable25
# Create the new backport branch
git checkout -b fix/foo-stable25
# Cherry pick the change from the commit sha1 of the change against the default branch# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@tsdicloud

Copy link
Copy Markdown
Contributor

Perfect. You helped me to save some nerves for the next release!

@juliusknorr

Copy link
Copy Markdown
Member

@max-nextcloud Can you take care of the manual backports?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@max-nextcloud@juliusknorr@tsdicloud@ChristophWurst@github-advanced-security@skjnldsv@szaimen