diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-04-17 10:46:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 10:46:06 +0200 |
commit | 9c5d32f5b3d83e120b582a4f24747e6bfdc5780c (patch) | |
tree | e71df1d0c9c7933e09a3d5185e8e2bc5ddfd823c | |
parent | 244054539446f8360ccb7e14149aa2784b4a14ac (diff) | |
parent | e9ff1216ad8fcbc10340134e2443c6e3693486fd (diff) | |
download | nextcloud-server-9c5d32f5b3d83e120b582a4f24747e6bfdc5780c.tar.gz nextcloud-server-9c5d32f5b3d83e120b582a4f24747e6bfdc5780c.zip |
Merge pull request #44740 from nextcloud/backport/stable26/44736
[stable26] fix: Fix avatar images
-rw-r--r-- | lib/private/Avatar/AvatarManager.php | 7 | ||||
-rw-r--r-- | tests/lib/Avatar/AvatarManagerTest.php | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/Avatar/AvatarManager.php b/lib/private/Avatar/AvatarManager.php index 4125c8eb0a8..6bcfa175ba0 100644 --- a/lib/private/Avatar/AvatarManager.php +++ b/lib/private/Avatar/AvatarManager.php @@ -101,6 +101,9 @@ class AvatarManager implements IAvatarManager { /** * 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 @@ -113,6 +116,10 @@ class AvatarManager implements IAvatarManager { 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(); diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php index 06ff4086f72..7d09440155c 100644 --- a/tests/lib/Avatar/AvatarManagerTest.php +++ b/tests/lib/Avatar/AvatarManagerTest.php @@ -108,6 +108,11 @@ class AvatarManagerTest extends \Test\TestCase { ->method('getUID') ->willReturn('valid-user'); + $user + ->expects($this->any()) + ->method('isEnabled') + ->willReturn(true); + // requesting user $this->userSession->expects($this->once()) ->method('getUser') @@ -162,6 +167,11 @@ class AvatarManagerTest extends \Test\TestCase { ->method('getUID') ->willReturn('valid-user'); + $user + ->expects($this->any()) + ->method('isEnabled') + ->willReturn(true); + $this->userSession->expects($this->once()) ->method('getUser') ->willReturn($user); @@ -231,6 +241,12 @@ class AvatarManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('getUID') ->willReturn('valid-user'); + + $user + ->expects($this->any()) + ->method('isEnabled') + ->willReturn(true); + $this->userManager ->expects($this->once()) ->method('get') |