diff --git a/middleware/envcheckmiddleware.php b/middleware/envcheckmiddleware.php index 8c9ee37525..c2385c27b2 100644 --- a/middleware/envcheckmiddleware.php +++ b/middleware/envcheckmiddleware.php @@ -267,7 +267,7 @@ private function checkPassword($share, $password) { $newHash = ''; if ($this->shareManager->checkPassword($share, $password)) { // Save item id in session for future requests - $this->session->set('public_link_authenticated', $share->getId()); + $this->session->set('public_link_authenticated', (string)$share->getId()); // @codeCoverageIgnoreStart if (!empty($newHash)) { // For future use @@ -289,7 +289,7 @@ private function checkPassword($share, $password) { private function checkSession($share) { // Not authenticated ? if (!$this->session->exists('public_link_authenticated') - || $this->session->get('public_link_authenticated') !== $share->getId() + || $this->session->get('public_link_authenticated') !== (string)$share->getId() ) { throw new CheckException("Missing password", Http::STATUS_UNAUTHORIZED); } diff --git a/tests/unit/middleware/EnvCheckMiddlewareTest.php b/tests/unit/middleware/EnvCheckMiddlewareTest.php index c744c492f5..aaef19225c 100644 --- a/tests/unit/middleware/EnvCheckMiddlewareTest.php +++ b/tests/unit/middleware/EnvCheckMiddlewareTest.php @@ -214,8 +214,8 @@ public function testBeforeControllerWithGuestNotation() { public function testCheckSessionAfterPasswordEntry() { $share = $this->mockShare('file', 'tester', 'image.png'); - $this->mockSessionExists($share->getId()); - $this->mockSessionWithShareId($share->getId()); + $this->mockSessionExists((string)$share->getId()); + $this->mockSessionWithShareId((string)$share->getId()); parent::invokePrivate($this->middleware, 'checkSession', [$share]); } @@ -365,8 +365,8 @@ public function testCheckAuthorisationWithNoPassword() { Constants::PERMISSION_READ, $wrongPassword ); - $this->mockSessionExists($share->getId()); - $this->mockSessionWithShareId($share->getId()); + $this->mockSessionExists((string)$share->getId()); + $this->mockSessionWithShareId((string)$share->getId()); parent::invokePrivate($this->middleware, 'checkAuthorisation', [$share, $password]); }