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 comodoInstalled = false;
|
||||
var counterOWASP = 0;
|
||||
var counterComodo = 0;
|
||||
var owaspInitialized = false;
|
||||
var comodoInitialized = false;
|
||||
|
||||
|
||||
$('#owaspInstalled').change(function () {
|
||||
@@ -1233,15 +1233,13 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
||||
owaspInstalled = $(this).prop('checked');
|
||||
$scope.ruleFiles = true;
|
||||
|
||||
if (counterOWASP !== 0) {
|
||||
if (owaspInitialized) {
|
||||
if (owaspInstalled === true) {
|
||||
installModSecRulesPack('installOWASP');
|
||||
} else {
|
||||
installModSecRulesPack('disableOWASP')
|
||||
}
|
||||
}
|
||||
|
||||
counterOWASP = counterOWASP + 1;
|
||||
});
|
||||
|
||||
$('#comodoInstalled').change(function () {
|
||||
@@ -1249,7 +1247,7 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
||||
$scope.ruleFiles = true;
|
||||
comodoInstalled = $(this).prop('checked');
|
||||
|
||||
if (counterComodo !== 0) {
|
||||
if (comodoInitialized) {
|
||||
|
||||
if (comodoInstalled === true) {
|
||||
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);
|
||||
$scope.owaspDisable = true;
|
||||
}
|
||||
// Mark as initialized after setting initial state
|
||||
owaspInitialized = true;
|
||||
|
||||
if (response.data.comodoInstalled === 1) {
|
||||
$('#comodoInstalled').prop('checked', true);
|
||||
$scope.comodoDisable = false;
|
||||
@@ -1305,6 +1304,8 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
|
||||
$('#comodoInstalled').prop('checked', false);
|
||||
$scope.comodoDisable = true;
|
||||
}
|
||||
// Mark as initialized after setting initial state
|
||||
comodoInitialized = true;
|
||||
} else {
|
||||
|
||||
if (response.data.owaspInstalled === 1) {
|
||||
|
||||
Reference in New Issue
Block a user