Skip to content

Commit

Permalink
Merge pull request #44740 from nextcloud/backport/stable26/44736
Browse files Browse the repository at this point in the history
[stable26] fix: Fix avatar images
  • Loading branch information
nickvergessen authored Apr 17, 2024
2 parents 2440545 + e9ff121 commit 9c5d32f
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 @@ -101,6 +101,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 @@ -113,6 +116,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 9c5d32f

Please sign in to comment.