Skip to content

Commit

Permalink
Merge pull request #44742 from nextcloud/backport/stable24/44736
Browse files Browse the repository at this point in the history
[stable24] fix: Fix avatar images
  • Loading branch information
nickvergessen authored Apr 17, 2024
2 parents 31c2610 + ebfac5f commit bf5792a
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 @@ -107,6 +107,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 @@ -161,6 +166,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 @@ -230,6 +240,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 bf5792a

Please sign in to comment.