Merge pull request #44736 from nextcloud/fix/avatar-images

fix: Fix avatar images
feat/assetlinks-json
Pytal 2 months ago committed by GitHub
commit 728c46d174
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -69,6 +69,9 @@ class AvatarManager implements IAvatarManager {
/** /**
* return a user specific instance of \OCP\IAvatar * return a user specific instance of \OCP\IAvatar
*
* If the user is disabled a guest avatar will be returned
*
* @see \OCP\IAvatar * @see \OCP\IAvatar
* @param string $userId the ownCloud user id * @param string $userId the ownCloud user id
* @throws \Exception In case the username is potentially dangerous * @throws \Exception In case the username is potentially dangerous
@ -80,6 +83,10 @@ class AvatarManager implements IAvatarManager {
throw new \Exception('user does not exist'); 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) // sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
$userId = $user->getUID(); $userId = $user->getUID();

@ -108,6 +108,11 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUID') ->method('getUID')
->willReturn('valid-user'); ->willReturn('valid-user');
$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);
// requesting user // requesting user
$this->userSession->expects($this->once()) $this->userSession->expects($this->once())
->method('getUser') ->method('getUser')
@ -162,6 +167,11 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUID') ->method('getUID')
->willReturn('valid-user'); ->willReturn('valid-user');
$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);
$this->userSession->expects($this->once()) $this->userSession->expects($this->once())
->method('getUser') ->method('getUser')
->willReturn($user); ->willReturn($user);
@ -231,6 +241,12 @@ class AvatarManagerTest extends \Test\TestCase {
->expects($this->once()) ->expects($this->once())
->method('getUID') ->method('getUID')
->willReturn('valid-user'); ->willReturn('valid-user');
$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);
$this->userManager $this->userManager
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')

Loading…
Cancel
Save