aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-03 22:25:03 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-09-11 17:53:16 +0000
commit1f748ded7ed4a2ce5ebf1233e1df25e97f619d8c (patch)
tree5834d19c753bf0f694beadff1c87f887f90b7919 /apps
parent7575e870ca654b9fbb808140d755a76ec55f3bbc (diff)
downloadnextcloud-server-1f748ded7ed4a2ce5ebf1233e1df25e97f619d8c.tar.gz
nextcloud-server-1f748ded7ed4a2ce5ebf1233e1df25e97f619d8c.zip
fix(ldap): avatar is not being fetched
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/User/User.php11
-rw-r--r--apps/user_ldap/tests/User/UserTest.php12
2 files changed, 20 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index f85e4206eff..cc80ac7a875 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -714,7 +714,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;
}
@@ -728,6 +728,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
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index 470b0829868..23ce407dfd7 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -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')