Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always use display name from correct backend #39770

Merged

Conversation

max-nextcloud
Copy link
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-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from c3058b0 to cbc436e Compare August 9, 2023 07:36
@juliushaertl
Copy link
Member

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

@max-nextcloud max-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from cbc436e to 136c804 Compare August 9, 2023 14:36
@@ -744,6 +745,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());
Copy link
Contributor Author

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
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
Contributor Author

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
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-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from 136c804 to b78d2fc Compare August 14, 2023 06:38
@max-nextcloud max-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from b78d2fc to b72e979 Compare August 14, 2023 06:45
@szaimen szaimen added the 3. to review Waiting for reviews label Aug 14, 2023
@szaimen szaimen added this to the Nextcloud 28 milestone Aug 14, 2023
@max-nextcloud max-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from b72e979 to d3ce30c Compare August 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-nextcloud force-pushed the fix/always-use-displayname-from-correct-backend branch from d3ce30c to 99a4a9c Compare August 15, 2023 12:55
Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@juliushaertl
Copy link
Member

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

Copy link
Member

@ChristophWurst ChristophWurst left a comment

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
Contributor Author

/backport to stable27

@max-nextcloud
Copy link
Contributor Author

/backport to stable26

@max-nextcloud
Copy link
Contributor Author

/backport to stable25

@max-nextcloud max-nextcloud merged commit 4b7aa65 into master Aug 17, 2023
40 checks passed
@max-nextcloud max-nextcloud deleted the fix/always-use-displayname-from-correct-backend branch August 17, 2023 21:10
@backportbot-nextcloud
Copy link

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

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
Contributor

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

@juliushaertl
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants