aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-09-11 19:43:18 +0200
committerGitHub <noreply@github.com>2023-09-11 19:43:18 +0200
commit97dd09c4348ebbd88089cf572ac18e6cdf341493 (patch)
tree90aa5e3c61717bc16edb10ed1a88808cc5e62f1a /apps/user_ldap/lib
parent9e2b2484317d2380baa46c7edd858c697dd51f9b (diff)
parent4054a7ddc8c29ae1cfb71507f7145257a0b08152 (diff)
downloadnextcloud-server-97dd09c4348ebbd88089cf572ac18e6cdf341493.tar.gz
nextcloud-server-97dd09c4348ebbd88089cf572ac18e6cdf341493.zip
Merge pull request #39128 from nextcloud/fix/35319/ldap-missing-avatar
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/User/User.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index dac8bf1cfbc..0de30a18899 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -695,9 +695,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;
}
@@ -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