mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-12-15 12:59:42 +01:00
Fix ModSecurity OWASP rules toggle not working on first click
Replace counter-based logic with initialization flags to properly handle toggle state changes. The previous implementation used counters that would block the first user click from triggering install/uninstall actions.
This commit is contained in:
@@ -1224,8 +1224,8 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
var owaspInstalled = false;
|
var owaspInstalled = false;
|
||||||
var comodoInstalled = false;
|
var comodoInstalled = false;
|
||||||
var counterOWASP = 0;
|
var owaspInitialized = false;
|
||||||
var counterComodo = 0;
|
var comodoInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
$('#owaspInstalled').change(function () {
|
$('#owaspInstalled').change(function () {
|
||||||
@@ -1233,15 +1233,13 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
owaspInstalled = $(this).prop('checked');
|
owaspInstalled = $(this).prop('checked');
|
||||||
$scope.ruleFiles = true;
|
$scope.ruleFiles = true;
|
||||||
|
|
||||||
if (counterOWASP !== 0) {
|
if (owaspInitialized) {
|
||||||
if (owaspInstalled === true) {
|
if (owaspInstalled === true) {
|
||||||
installModSecRulesPack('installOWASP');
|
installModSecRulesPack('installOWASP');
|
||||||
} else {
|
} else {
|
||||||
installModSecRulesPack('disableOWASP')
|
installModSecRulesPack('disableOWASP')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
counterOWASP = counterOWASP + 1;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#comodoInstalled').change(function () {
|
$('#comodoInstalled').change(function () {
|
||||||
@@ -1249,7 +1247,7 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.ruleFiles = true;
|
$scope.ruleFiles = true;
|
||||||
comodoInstalled = $(this).prop('checked');
|
comodoInstalled = $(this).prop('checked');
|
||||||
|
|
||||||
if (counterComodo !== 0) {
|
if (comodoInitialized) {
|
||||||
|
|
||||||
if (comodoInstalled === true) {
|
if (comodoInstalled === true) {
|
||||||
installModSecRulesPack('installComodo');
|
installModSecRulesPack('installComodo');
|
||||||
@@ -1258,8 +1256,6 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
counterComodo = counterComodo + 1;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -1298,6 +1294,9 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
$('#owaspInstalled').prop('checked', false);
|
$('#owaspInstalled').prop('checked', false);
|
||||||
$scope.owaspDisable = true;
|
$scope.owaspDisable = true;
|
||||||
}
|
}
|
||||||
|
// Mark as initialized after setting initial state
|
||||||
|
owaspInitialized = true;
|
||||||
|
|
||||||
if (response.data.comodoInstalled === 1) {
|
if (response.data.comodoInstalled === 1) {
|
||||||
$('#comodoInstalled').prop('checked', true);
|
$('#comodoInstalled').prop('checked', true);
|
||||||
$scope.comodoDisable = false;
|
$scope.comodoDisable = false;
|
||||||
@@ -1305,6 +1304,8 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
|||||||
$('#comodoInstalled').prop('checked', false);
|
$('#comodoInstalled').prop('checked', false);
|
||||||
$scope.comodoDisable = true;
|
$scope.comodoDisable = true;
|
||||||
}
|
}
|
||||||
|
// Mark as initialized after setting initial state
|
||||||
|
comodoInitialized = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (response.data.owaspInstalled === 1) {
|
if (response.data.owaspInstalled === 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user