mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-17 21:12:14 +01:00
Merge pull request #5202 from nextcloud/fix/5199
fix: Properly handle authenticated links being an array
This commit is contained in:
commit
fcbf00a8d6
2 changed files with 16 additions and 9 deletions
|
|
@ -65,9 +65,11 @@ class DocumentAPIController extends \OCP\AppFramework\OCSController {
|
|||
$share = $this->shareManager->getShareByToken($shareToken);
|
||||
|
||||
if ($share->getPassword()) {
|
||||
if (!$this->session->exists('public_link_authenticated')
|
||||
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
|
||||
) {
|
||||
$authenticatedLinks = $this->session->get('public_link_authenticated');
|
||||
|
||||
$isAuthenticated = (is_array($authenticatedLinks) && in_array($share->getId(), $authenticatedLinks));
|
||||
$isAuthenticated = $isAuthenticated || ($authenticatedLinks === (string)$share->getId());
|
||||
if (!$isAuthenticated) {
|
||||
throw new Exception('Invalid password');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,9 +242,11 @@ class DocumentController extends Controller {
|
|||
$share = $this->shareManager->getShareByToken($shareToken);
|
||||
// not authenticated ?
|
||||
if ($share->getPassword()) {
|
||||
if (!$this->session->exists('public_link_authenticated')
|
||||
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
|
||||
) {
|
||||
$authenticatedLinks = $this->session->get('public_link_authenticated');
|
||||
|
||||
$isAuthenticated = (is_array($authenticatedLinks) && in_array($share->getId(), $authenticatedLinks));
|
||||
$isAuthenticated = $isAuthenticated || ($authenticatedLinks === (string)$share->getId());
|
||||
if (!$isAuthenticated) {
|
||||
throw new Exception('Invalid password');
|
||||
}
|
||||
}
|
||||
|
|
@ -459,9 +461,12 @@ class DocumentController extends Controller {
|
|||
private function getFileForShare(IShare $share, ?int $fileId, ?string $path = null): File {
|
||||
// not authenticated ?
|
||||
if ($share->getPassword()) {
|
||||
if (!$this->session->exists('public_link_authenticated')
|
||||
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
|
||||
) {
|
||||
$authenticatedLinks = $this->session->get('public_link_authenticated');
|
||||
|
||||
$isAuthenticated = (is_array($authenticatedLinks) && in_array($share->getId(), $authenticatedLinks));
|
||||
$isAuthenticated = $isAuthenticated || ($authenticatedLinks === (string)$share->getId());
|
||||
|
||||
if (!$isAuthenticated) {
|
||||
throw new NotPermittedException('Invalid password');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue