fix: Avoid throwing errors if no token provided on close
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -29,6 +29,8 @@ use OCA\Deck\Db\BoardMapper;
|
|||||||
use OCA\Deck\Service\PermissionService;
|
use OCA\Deck\Service\PermissionService;
|
||||||
use OCA\Deck\Service\SessionService;
|
use OCA\Deck\Service\SessionService;
|
||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||||
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\OCSController;
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
@@ -43,9 +45,7 @@ class SessionController extends OCSController {
|
|||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[NoAdminRequired]
|
||||||
* @NoAdminRequired
|
|
||||||
*/
|
|
||||||
public function create(int $boardId): DataResponse {
|
public function create(int $boardId): DataResponse {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||||
|
|
||||||
@@ -55,11 +55,7 @@ class SessionController extends OCSController {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[NoAdminRequired]
|
||||||
* notifies the server that the session is still active
|
|
||||||
* @NoAdminRequired
|
|
||||||
* @param $boardId
|
|
||||||
*/
|
|
||||||
public function sync(int $boardId, string $token): DataResponse {
|
public function sync(int $boardId, string $token): DataResponse {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||||
try {
|
try {
|
||||||
@@ -70,13 +66,12 @@ class SessionController extends OCSController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[NoAdminRequired]
|
||||||
* delete a session if existing
|
#[NoCSRFRequired]
|
||||||
* @NoAdminRequired
|
public function close(int $boardId, string $token = null): DataResponse {
|
||||||
* @NoCSRFRequired
|
if ($token === null) {
|
||||||
* @param $boardId
|
return new DataResponse();
|
||||||
*/
|
}
|
||||||
public function close(int $boardId, string $token) {
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||||
$this->sessionService->closeSession($boardId, $token);
|
$this->sessionService->closeSession($boardId, $token);
|
||||||
return new DataResponse();
|
return new DataResponse();
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export function createSession(boardId) {
|
|||||||
|
|
||||||
// close session when tab gets hidden/inactive
|
// close session when tab gets hidden/inactive
|
||||||
const visibilitychangeListener = () => {
|
const visibilitychangeListener = () => {
|
||||||
if (document.visibilityState === 'hidden') {
|
if (document.visibilityState === 'hidden' && token) {
|
||||||
sessionApi.closeSessionViaBeacon(boardId, token)
|
sessionApi.closeSessionViaBeacon(boardId, token)
|
||||||
tokenPromise = null
|
tokenPromise = null
|
||||||
token = null
|
token = null
|
||||||
|
|||||||
Reference in New Issue
Block a user