mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	fix: Add UserProviderInterface dependency.
This commit is contained in:
		| @@ -19,6 +19,7 @@ use Psr\Http\Client\ClientInterface; | ||||
| use Psr\Http\Message\RequestInterface; | ||||
| use Psr\Http\Message\ResponseInterface; | ||||
| use Symfony\Component\Security\Core\Security; | ||||
| use Symfony\Component\Security\Core\User\UserProviderInterface; | ||||
|  | ||||
| final class ChillWopi implements WopiInterface | ||||
| { | ||||
| @@ -34,13 +35,16 @@ final class ChillWopi implements WopiInterface | ||||
|  | ||||
|     private Security $security; | ||||
|  | ||||
|     private UserProviderInterface $userProvider; | ||||
|  | ||||
|     public function __construct( | ||||
|         Psr17Interface $psr17, | ||||
|         WopiDiscoveryInterface $wopiDiscovery, | ||||
|         StoredObjectRepository $storedObjectRepository, | ||||
|         ClientInterface $httpClient, | ||||
|         TempUrlGeneratorInterface $tempUrlGeneratorInterface, | ||||
|         Security $security | ||||
|         Security $security, | ||||
|         UserProviderInterface $userProvider | ||||
|     ) { | ||||
|         $this->psr17 = $psr17; | ||||
|         $this->wopiDiscovery = $wopiDiscovery; | ||||
| @@ -48,6 +52,7 @@ final class ChillWopi implements WopiInterface | ||||
|         $this->httpClient = $httpClient; | ||||
|         $this->tempUrlGeneratorInterface = $tempUrlGeneratorInterface; | ||||
|         $this->security = $security; | ||||
|         $this->userProvider = $userProvider; | ||||
|     } | ||||
|  | ||||
|     public function checkFileInfo( | ||||
| @@ -55,6 +60,8 @@ final class ChillWopi implements WopiInterface | ||||
|         ?string $accessToken, | ||||
|         RequestInterface $request | ||||
|     ): ResponseInterface { | ||||
|         $user = $this->userProvider->loadUserByUsername($accessToken); | ||||
|  | ||||
|         $storedObject = $this->storedObjectRepository->findOneBy(['filename' => $fileId]); | ||||
|  | ||||
|         if (null === $storedObject) { | ||||
| @@ -74,15 +81,15 @@ final class ChillWopi implements WopiInterface | ||||
|             ->withBody($this->psr17->createStream((string) json_encode( | ||||
|                 [ | ||||
|                     'BaseFileName' => $storedObject->getFilename(), | ||||
|                     'OwnerId' => $this->security->getUser()->getUsername(), | ||||
|                     'OwnerId' => $user->getUsername(), | ||||
|                     'Size' => 0, | ||||
|                     'UserId' => $this->security->getUser()->getUsername(), | ||||
|                     'UserId' => $user->getUsername(), | ||||
| //                    'Version' => 'v' . uniqid(), | ||||
|                     'ReadOnly' => false, | ||||
|                     'UserCanWrite' => true, | ||||
|                     'UserCanNotWriteRelative' => false, | ||||
|                     'SupportsLocks' => true, | ||||
|                     'UserFriendlyName' => sprintf('User %s', $this->security->getUser()->getUsername()), | ||||
|                     'UserFriendlyName' => sprintf('User %s', $user->getUsername()), | ||||
|                     'UserExtraInfo' => [], | ||||
|                     'LastModifiedTime' => date('Y-m-d\TH:i:s.u\Z', $storedObject->getCreationDate()->getTimestamp()), | ||||
|                     'CloseButtonClosesWindow' => true, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user