From ded2ad75446f076caade8db4b7d78003d5a6facc Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 29 Nov 2019 16:48:05 +0300 Subject: [PATCH] always set userId --- controller/callbackcontroller.php | 33 ++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 83e5a78d..f47aa82b 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -212,13 +212,13 @@ public function download($doc) { if ($this->userSession->isLoggedIn()) { $userId = $this->userSession->getUser()->getUID(); } else { + \OC_Util::tearDownFS(); + $userId = $hashData->userId; - $user = $this->userManager->get($userId); + \OC_User::setUserId($userId); + $user = $this->userManager->get($userId); if (!empty($user)) { - $this->userSession->setUser($user); - - \OC_Util::tearDownFS(); \OC_Util::setupFS($userId); } } @@ -382,27 +382,24 @@ public function track($doc, $users, $key, $status, $url, $token) { try { $shareToken = isset($hashData->shareToken) ? $hashData->shareToken : NULL; + \OC_Util::tearDownFS(); + + // author of the latest changes $userId = $users[0]; - $user = $this->userManager->get($userId); + \OC_User::setUserId($userId); + $user = $this->userManager->get($userId); if (!empty($user)) { - $this->userSession->setUser($user); - - \OC_Util::tearDownFS(); \OC_Util::setupFS($userId); } else { if (empty($shareToken)) { - $this->logger->debug("Track without token: $fileId status $trackerStatus", array("app" => $this->appName)); - - $callbackUserId = $hashData->userId; - $callbackUser = $this->userManager->get($callbackUserId); - - if (!empty($callbackUser)) { - $userId = $callbackUserId; - } + // author of the callback link + $userId = $hashData->userId; + \OC_User::setUserId($userId); + $this->logger->debug("Track for $userId: $fileId status $trackerStatus", array("app" => $this->appName)); - \OC_Util::tearDownFS(); - if (!empty($userId)) { + $user = $this->userManager->get($userId); + if (!empty($user)) { \OC_Util::setupFS($userId); } } else {