Remove CSRF token validation to match configuration page

CSRF Fix:
- Removed dolibarr_checkToken() validation
- Simplified form processing logic
- Matches the same approach used in setup_mvp.php
- Form now works without CSRF protection issues

This ensures consistency with the configuration page approach.
This commit is contained in:
Frank Cools 2025-10-02 18:17:58 +02:00
parent 480d3c5deb
commit 12c5329577

View File

@ -45,25 +45,20 @@ $end_date = GETPOST('end_date', 'alpha');
$error = '';
$success = '';
if ($action == 'create') {
// Check CSRF token
if (!dolibarr_checkToken()) {
$error = $langs->trans("ErrorCSRFToken");
} elseif (!empty($start_date) && !empty($end_date)) {
// Create the declaration with dates
$declaration_id = $declarationtva->createDeclarationWithDates($start_date, $end_date, $declaration_name);
if ($declaration_id > 0) {
$success = $langs->trans("DeclarationCreated");
// Redirect to view the created declaration
header("Location: declarationtva_view.php?id=" . $declaration_id);
exit;
} else {
$error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error;
}
if ($action == 'create' && !empty($start_date) && !empty($end_date)) {
// Create the declaration with dates
$declaration_id = $declarationtva->createDeclarationWithDates($start_date, $end_date, $declaration_name);
if ($declaration_id > 0) {
$success = $langs->trans("DeclarationCreated");
// Redirect to view the created declaration
header("Location: declarationtva_view.php?id=" . $declaration_id);
exit;
} else {
$error = $langs->trans("ErrorMissingDates");
$error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error;
}
} elseif ($action == 'create' && (empty($start_date) || empty($end_date))) {
$error = $langs->trans("ErrorMissingDates");
}
// Page title