Skip to content

Commit

Permalink
Merge pull request #44741 from nextcloud/backport/stable25/44736
Browse files Browse the repository at this point in the history
[stable25] fix: Fix avatar images
  • Loading branch information
nickvergessen authored Apr 17, 2024
2 parents a2231dc + fb42992 commit 4f6ba65
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/private/Avatar/AvatarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function __construct(

/**
* return a user specific instance of \OCP\IAvatar
*
* If the user is disabled a guest avatar will be returned
*
* @see \OCP\IAvatar
* @param string $userId the ownCloud user id
* @return \OCP\IAvatar
Expand All @@ -114,6 +117,10 @@ public function getAvatar(string $userId) : IAvatar {
throw new \Exception('user does not exist');
}

if (!$user->isEnabled()) {
return $this->getGuestAvatar($userId);
}

// sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
$userId = $user->getUID();

Expand Down
16 changes: 16 additions & 0 deletions tests/lib/Avatar/AvatarManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public function testGetAvatarForSelf() {
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

// requesting user
$this->userSession->expects($this->once())
->method('getUser')
Expand Down Expand Up @@ -162,6 +167,11 @@ public function testGetAvatarValidUserDifferentCasing() {
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand Down Expand Up @@ -231,6 +241,12 @@ public function testGetAvatarScopes($avatarScope, $isPublicCall, $isKnownUser, $
->expects($this->once())
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

$this->userManager
->expects($this->once())
->method('get')
Expand Down

0 comments on commit 4f6ba65

Please sign in to comment.