Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(ldap): avatar is not being fetched
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and backportbot-nextcloud[bot] committed Sep 11, 2023
commit 2c3badc32a6049aaa21f9d20329ca2833587cfef
11 changes: 10 additions & 1 deletion apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function updateAvatar($force = false) {
// 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;
}

Expand All @@ -558,6 +558,15 @@ public function updateAvatar($force = false) {
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
Expand Down
12 changes: 10 additions & 2 deletions apps/user_ldap/tests/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,17 @@ public function testUpdateAvatarKnownJpegPhotoProvided() {
$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')
Expand Down