Skip to content

Commit 0a26ce9

Browse files
committed
fix: prevent missing addressed vulnerability through intervention policy
1 parent c4b0ca0 commit 0a26ce9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

app/Policies/InterventionPolicy.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,27 @@ public function update(User $user, Intervention $intervention): bool
4646
return false;
4747
}
4848

49-
return $this->view($user, $intervention);
49+
if (! $this->view($user, $intervention)) {
50+
return false;
51+
}
52+
53+
return $intervention->beneficiary
54+
->catagraphy
55+
->all_vulnerabilities_items
56+
->pluck('value')
57+
->contains($intervention->vulnerability_id);
5058
}
5159

5260
/**
5361
* Determine whether the user can delete the model.
5462
*/
5563
public function delete(User $user, Intervention $intervention): bool
5664
{
57-
return $this->update($user, $intervention);
65+
if (! $intervention->isOpen()) {
66+
return false;
67+
}
68+
69+
return $this->view($user, $intervention);
5870
}
5971

6072
/**

0 commit comments

Comments
 (0)