Skip to content

Commit c948ccf

Browse files
authored
Merge pull request #1084 from itflow-org/budget-perms
Budget - CSRF + Perms
2 parents 5ea2716 + f8c6a5e commit c948ccf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

budget_edit.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require_once "inc_all.php";
44

5+
enforceUserPermission('module_financial', 2);
6+
57
// Fetch categories
68
$query = "SELECT category_id, category_name FROM categories WHERE category_type ='Expense' AND category_archived_at IS NULL";
79
$result = mysqli_query($mysqli, $query);
@@ -52,6 +54,8 @@
5254
</form>
5355
<form id="budgetForm" method="POST" action="post.php">
5456
<input type="hidden" name="year" value="<?php echo $currentYear; ?>">
57+
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
58+
5559
<table class="table table-bordered table-striped">
5660
<thead>
5761
<tr>

post/user/budget.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
*/
66

77
if (isset($_POST['save_budget'])) {
8+
9+
enforceUserPermission('module_financial', 2);
10+
11+
validateCSRFToken($_POST['csrf_token']);
12+
813
$budgets = $_POST['budget'];
914
$year = intval($_POST['year']);
1015

@@ -37,6 +42,11 @@
3742
}
3843

3944
if (isset($_POST['delete_budget'])) {
45+
46+
enforceUserPermission('module_financial', 3);
47+
48+
validateCSRFToken($_POST['csrf_token']);
49+
4050
$year = intval($_POST['year']);
4151

4252
mysqli_query($mysqli,"DELETE FROM budget WHERE budget_year = $year");

0 commit comments

Comments
 (0)