Skip to content

Commit f66cb55

Browse files
authored
Merge pull request #712 from nextcloud/fix/711
fix: Properly handle authenticated links being an array
2 parents e7763d7 + 1a64546 commit f66cb55

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lib/Controller/DocumentController.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,11 @@ public function publicPage($shareToken, $fileName, $fileId) {
340340
$share = $this->shareManager->getShareByToken($shareToken);
341341
// not authenticated ?
342342
if ($share->getPassword()) {
343-
if (!$this->session->exists('public_link_authenticated')
344-
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
345-
) {
343+
$authenticatedLinks = $this->session->get('public_link_authenticated');
344+
345+
$isAuthenticated = (is_array($authenticatedLinks) && in_array($share->getId(), $authenticatedLinks));
346+
$isAuthenticated = $isAuthenticated || ($authenticatedLinks === (string)$share->getId());
347+
if (!$isAuthenticated) {
346348
throw new \Exception('Invalid password');
347349
}
348350
}
@@ -394,9 +396,11 @@ public function remote($shareToken, $remoteServer, $remoteServerToken, $filePath
394396
$share = $this->shareManager->getShareByToken($shareToken);
395397
// not authenticated ?
396398
if ($share->getPassword()) {
397-
if (!$this->session->exists('public_link_authenticated')
398-
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
399-
) {
399+
$authenticatedLinks = $this->session->get('public_link_authenticated');
400+
401+
$isAuthenticated = (is_array($authenticatedLinks) && in_array($share->getId(), $authenticatedLinks));
402+
$isAuthenticated = $isAuthenticated || ($authenticatedLinks === (string)$share->getId());
403+
if (!$isAuthenticated) {
400404
throw new \Exception('Invalid password');
401405
}
402406
}

0 commit comments

Comments
 (0)