diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-11-29 22:17:52 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-12-02 14:28:31 +0300 |
commit | 6a3b6018d26ba752da94046938477e786f19efac (patch) | |
tree | 1e447b090e2471d41322a79d78d01b9ba17308f0 | |
parent | c87396aa85c09c2344c3982f87a4e28ea4b7f273 (diff) |
Use DI for direct editing token handling
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | lib/Service/DocumentService.php | 9 | ||||
-rw-r--r-- | lib/Service/SessionService.php | 12 |
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index 27be4956d..6dc254355 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -28,6 +28,7 @@ namespace OCA\Text\Service; use \InvalidArgumentException; use OCA\Text\Db\Session; use OCP\DirectEditing\IManager; +use OCP\IRequest; use function json_encode; use OC\Files\Node\File; use OCA\Text\Db\Document; @@ -96,7 +97,7 @@ class DocumentService { */ private $appData; - public function __construct(DocumentMapper $documentMapper, StepMapper $stepMapper, IAppData $appData, $userId, IRootFolder $rootFolder, ICacheFactory $cacheFactory, ILogger $logger, ShareManager $shareManager) { + public function __construct(DocumentMapper $documentMapper, StepMapper $stepMapper, IAppData $appData, $userId, IRootFolder $rootFolder, ICacheFactory $cacheFactory, ILogger $logger, ShareManager $shareManager, IRequest $request, IManager $directManager) { $this->documentMapper = $documentMapper; $this->stepMapper = $stepMapper; $this->userId = $userId; @@ -111,12 +112,10 @@ class DocumentService { $this->appData->newFolder('documents'); } - // FIXME - $token = \OC::$server->getRequest()->getParam('token'); + $token = $request->getParam('token'); if ($this->userId === null && $token !== null) { - $this->directManager = \OC::$server->query(IManager::class); try { - $tokenObject = $this->directManager->getToken($token); + $tokenObject = $directManager->getToken($token); $tokenObject->extend(); $tokenObject->useTokenScope(); $this->userId = $tokenObject->getUser(); diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index 457fea497..81251e9da 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -32,6 +32,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\DirectEditing\IManager; use OCP\IAvatar; use OCP\IAvatarManager; +use OCP\IRequest; use OCP\Security\ISecureRandom; class SessionService { @@ -47,23 +48,22 @@ class SessionService { /** @var Session cache current session in the request */ private $session = null; - public function __construct(SessionMapper $sessionMapper, ISecureRandom $secureRandom, ITimeFactory $timeFactory, IAvatarManager $avatarManager, $userId) { + public function __construct(SessionMapper $sessionMapper, ISecureRandom $secureRandom, ITimeFactory $timeFactory, IAvatarManager $avatarManager, IRequest $request, IManager $directManager, $userId) { $this->sessionMapper = $sessionMapper; $this->secureRandom = $secureRandom; $this->timeFactory = $timeFactory; + $this->avatarManager = $avatarManager; $this->userId = $userId; - // FIXME - $token = \OC::$server->getRequest()->getParam('token'); + + $token = $request->getParam('token'); if ($this->userId === null && $token !== null) { - $this->directManager = \OC::$server->query(IManager::class); try { - $tokenObject = $this->directManager->getToken($token); + $tokenObject = $directManager->getToken($token); $tokenObject->extend(); $tokenObject->useTokenScope(); $this->userId = $tokenObject->getUser(); } catch (\Exception $e) {} } - $this->avatarManager = $avatarManager; } public function initSession($documentId, $guestName = null): Session { |