Skip to content

Commit

Permalink
Added error handling and user permission checking
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Aug 22, 2023
1 parent b35381b commit 91e1014
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions application/controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ public function getUserLogs() {
// Load the Log model
$this->load->model('LogModel');

// Check if the user has the necessary permissions
if (!$this->LogModel->check_permissions()) {
return array('status' => 'error', 'message' => 'Insufficient permissions');
}

// Retrieve the logs from the database
$logs = $this->LogModel->get_logs();

// Check if the get_logs function failed
if ($logs === false) {
return array('status' => 'error', 'message' => 'Failed to retrieve logs');
}

// Return the logs in an appropriate format
return array('status' => 'success', 'data' => $logs);
}
Expand All @@ -18,9 +28,19 @@ public function getProcessedConsignments() {
// Load the Consignment model
$this->load->model('ConsignmentModel');

// Check if the user has the necessary permissions
if (!$this->ConsignmentModel->check_permissions()) {
return array('status' => 'error', 'message' => 'Insufficient permissions');
}

// Retrieve the consignments from the database
$consignments = $this->ConsignmentModel->get_consignments();

// Check if the get_consignments function failed
if ($consignments === false) {
return array('status' => 'error', 'message' => 'Failed to retrieve consignments');
}

// Return the consignments in an appropriate format
return array('status' => 'success', 'data' => $consignments);
}
Expand Down

0 comments on commit 91e1014

Please sign in to comment.