mirror of
https://github.com/nextcloud/server.git
synced 2026-05-21 17:45:40 -04:00
Merge pull request #40370 from nextcloud/backport/39128/stable26
[stable26] fix(ldap): avatar is not being fetched
This commit is contained in:
commit
efde16a612
2 changed files with 22 additions and 5 deletions
|
|
@ -525,9 +525,9 @@ class User {
|
|||
|
||||
/**
|
||||
* @brief attempts to get an image from LDAP and sets it as Nextcloud avatar
|
||||
* @return bool
|
||||
* @return bool true when the avatar was set successfully or is up to date
|
||||
*/
|
||||
public function updateAvatar($force = false) {
|
||||
public function updateAvatar(bool $force = false): bool {
|
||||
if (!$force && $this->wasRefreshed('avatar')) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -544,7 +544,7 @@ class User {
|
|||
// use the checksum before modifications
|
||||
$checksum = md5($this->image->data());
|
||||
|
||||
if ($checksum === $this->config->getUserValue($this->uid, 'user_ldap', 'lastAvatarChecksum', '')) {
|
||||
if ($checksum === $this->config->getUserValue($this->uid, 'user_ldap', 'lastAvatarChecksum', '') && $this->avatarExists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -558,6 +558,15 @@ class User {
|
|||
return $isSet;
|
||||
}
|
||||
|
||||
private function avatarExists(): bool {
|
||||
try {
|
||||
$currentAvatar = $this->avatarManager->getAvatar($this->uid);
|
||||
return $currentAvatar->exists() && $currentAvatar->isCustomAvatar();
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sets an image as Nextcloud avatar
|
||||
* @return bool
|
||||
|
|
|
|||
|
|
@ -585,9 +585,17 @@ class UserTest extends \Test\TestCase {
|
|||
$avatar = $this->createMock(IAvatar::class);
|
||||
$avatar->expects($this->never())
|
||||
->method('set');
|
||||
$avatar->expects($this->any())
|
||||
->method('exists')
|
||||
->willReturn(true);
|
||||
$avatar->expects($this->any())
|
||||
->method('isCustomAvatar')
|
||||
->willReturn(true);
|
||||
|
||||
$this->avatarManager->expects($this->never())
|
||||
->method('getAvatar');
|
||||
$this->avatarManager->expects($this->any())
|
||||
->method('getAvatar')
|
||||
->with($this->uid)
|
||||
->willReturn($avatar);
|
||||
|
||||
$this->connection->expects($this->any())
|
||||
->method('resolveRule')
|
||||
|
|
|
|||
Loading…
Reference in a new issue