Skip to content

Commit d75a4c7

Browse files
fix: prevent clobbering session during model deletions in forms #630
1 parent 2d9968d commit d75a4c7

File tree

1 file changed

+4
-2
lines changed
  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

1 file changed

+4
-2
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Form {
132132

133133
# Gather information about the authenticated user
134134
$client = new Auth();
135-
$client->username = $_SESSION['Username'] ?: DEFAULT_CLIENT_USERNAME;
135+
$client->username = $_SESSION['Username'];
136136

137137
# Obtain the `id` from URL parameters
138138
$this->id = is_numeric($_GET['id']) ? intval($_GET['id']) : null;
@@ -403,7 +403,9 @@ class Form {
403403
}
404404

405405
try {
406-
(new $this->model(id: $id))->delete();
406+
$model_to_delete = new $this->model(id: $id);
407+
$model_to_delete->client = $this->model->client;
408+
$model_to_delete->delete();
407409
$this->print_success_banner("Deleted {$this->model->verbose_name} with ID $id.");
408410
} catch (Response $resp_error) {
409411
$error_message = $resp_error->getMessage();

0 commit comments

Comments
 (0)