Skip to content

Commit 4f6ba65

Browse files
Merge pull request #44741 from nextcloud/backport/stable25/44736
[stable25] fix: Fix avatar images
2 parents a2231dc + fb42992 commit 4f6ba65

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

lib/private/Avatar/AvatarManager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function __construct(
102102

103103
/**
104104
* return a user specific instance of \OCP\IAvatar
105+
*
106+
* If the user is disabled a guest avatar will be returned
107+
*
105108
* @see \OCP\IAvatar
106109
* @param string $userId the ownCloud user id
107110
* @return \OCP\IAvatar
@@ -114,6 +117,10 @@ public function getAvatar(string $userId) : IAvatar {
114117
throw new \Exception('user does not exist');
115118
}
116119

120+
if (!$user->isEnabled()) {
121+
return $this->getGuestAvatar($userId);
122+
}
123+
117124
// sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
118125
$userId = $user->getUID();
119126

tests/lib/Avatar/AvatarManagerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public function testGetAvatarForSelf() {
108108
->method('getUID')
109109
->willReturn('valid-user');
110110

111+
$user
112+
->expects($this->any())
113+
->method('isEnabled')
114+
->willReturn(true);
115+
111116
// requesting user
112117
$this->userSession->expects($this->once())
113118
->method('getUser')
@@ -162,6 +167,11 @@ public function testGetAvatarValidUserDifferentCasing() {
162167
->method('getUID')
163168
->willReturn('valid-user');
164169

170+
$user
171+
->expects($this->any())
172+
->method('isEnabled')
173+
->willReturn(true);
174+
165175
$this->userSession->expects($this->once())
166176
->method('getUser')
167177
->willReturn($user);
@@ -231,6 +241,12 @@ public function testGetAvatarScopes($avatarScope, $isPublicCall, $isKnownUser, $
231241
->expects($this->once())
232242
->method('getUID')
233243
->willReturn('valid-user');
244+
245+
$user
246+
->expects($this->any())
247+
->method('isEnabled')
248+
->willReturn(true);
249+
234250
$this->userManager
235251
->expects($this->once())
236252
->method('get')

0 commit comments

Comments
 (0)