Skip to content

Commit

Permalink
Fix rights checking for kanban delete/restore actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne authored and trasher committed Nov 6, 2024
1 parent b753b76 commit 12e3366
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ajax/kanban.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
}
if (in_array($action, ['delete_item'])) {
$maybe_deleted = $item->maybeDeleted();
if (($maybe_deleted && !$item::canDelete()) && (!$maybe_deleted && $item::canPurge())) {
if (($maybe_deleted && !$item::canDelete()) || (!$maybe_deleted && $item::canPurge())) {
// Missing rights
http_response_code(403);
return;
Expand Down Expand Up @@ -282,7 +282,7 @@
$item->getFromDB($_POST['items_id']);
// Check if the item can be trashed and if the request isn't forcing deletion (purge)
$maybe_deleted = $item->maybeDeleted() && !($_REQUEST['force'] ?? false);
if (($maybe_deleted && $item->canDeleteItem()) || (!$maybe_deleted && $item->canPurgeItem())) {
if (($maybe_deleted && $item->can($_POST['items_id'], DELETE)) || (!$maybe_deleted && $item->can($_POST['items_id'], PURGE))) {
$item->delete(['id' => $_POST['items_id']], !$maybe_deleted);
} else {
http_response_code(403);
Expand All @@ -293,7 +293,7 @@
$item->getFromDB($_POST['items_id']);
// Check if the item can be restored
$maybe_deleted = $item->maybeDeleted();
if (($maybe_deleted && $item->canDeleteItem())) {
if (($maybe_deleted && $item->can($_POST['items_id'], DELETE))) {
$item->restore(['id' => $_POST['items_id']]);
} else {
http_response_code(403);
Expand Down

0 comments on commit 12e3366

Please sign in to comment.