Skip to content

Commit 030ad0f

Browse files
authored
Merge pull request #5284 from nextcloud/bugfix/noid/no-token-session
2 parents bd515c1 + 4e10f80 commit 030ad0f

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

lib/Controller/SessionController.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
use OCA\Deck\Service\PermissionService;
3030
use OCA\Deck\Service\SessionService;
3131
use OCP\AppFramework\Db\DoesNotExistException;
32+
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
33+
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
3234
use OCP\AppFramework\Http\DataResponse;
3335
use OCP\AppFramework\OCSController;
3436
use OCP\IRequest;
@@ -43,9 +45,7 @@ public function __construct($appName,
4345
parent::__construct($appName, $request);
4446
}
4547

46-
/**
47-
* @NoAdminRequired
48-
*/
48+
#[NoAdminRequired]
4949
public function create(int $boardId): DataResponse {
5050
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
5151

@@ -55,11 +55,7 @@ public function create(int $boardId): DataResponse {
5555
]);
5656
}
5757

58-
/**
59-
* notifies the server that the session is still active
60-
* @NoAdminRequired
61-
* @param $boardId
62-
*/
58+
#[NoAdminRequired]
6359
public function sync(int $boardId, string $token): DataResponse {
6460
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
6561
try {
@@ -70,13 +66,12 @@ public function sync(int $boardId, string $token): DataResponse {
7066
}
7167
}
7268

73-
/**
74-
* delete a session if existing
75-
* @NoAdminRequired
76-
* @NoCSRFRequired
77-
* @param $boardId
78-
*/
79-
public function close(int $boardId, string $token) {
69+
#[NoAdminRequired]
70+
#[NoCSRFRequired]
71+
public function close(int $boardId, string $token = null): DataResponse {
72+
if ($token === null) {
73+
return new DataResponse();
74+
}
8075
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
8176
$this->sessionService->closeSession($boardId, $token);
8277
return new DataResponse();

src/sessions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function createSession(boardId) {
117117

118118
// close session when tab gets hidden/inactive
119119
const visibilitychangeListener = () => {
120-
if (document.visibilityState === 'hidden') {
120+
if (document.visibilityState === 'hidden' && token) {
121121
sessionApi.closeSessionViaBeacon(boardId, token)
122122
tokenPromise = null
123123
token = null

0 commit comments

Comments
 (0)