From 9a1ebccbc6abce6d129758eba03c14e68660753b Mon Sep 17 00:00:00 2001 From: usmannasir Date: Wed, 26 Nov 2025 22:09:43 +0500 Subject: [PATCH] Fix OWASP toggle: ensure flags reset and prevent loader on page load 1. Move flag reset outside conditional blocks - flags now always reset even if ModSecurity is not installed or AJAX fails 2. Reset flags in error handler (cantLoadInitialDatas) as well 3. Add showLoader parameter to getOWASPAndComodoStatus - loader only shows when explicitly requested, not during initial status check This fixes: - Toggle not responding to clicks (flags were stuck as true) - Spinner showing on initial page load (now only shows during install) --- firewall/static/firewall/firewall.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index 467b01ebd..fabddd43a 100644 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -1278,9 +1278,12 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) { getOWASPAndComodoStatus(true); - function getOWASPAndComodoStatus(updateToggle) { + function getOWASPAndComodoStatus(updateToggle, showLoader) { - $scope.modsecLoading = false; + // Only show loader if explicitly requested (during installations) + if (showLoader === true) { + $scope.modsecLoading = false; + } url = "/firewall/getOWASPAndComodoStatus"; @@ -1324,12 +1327,6 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) { $scope.comodoDisable = true; } - // Reset flags after toggle update - $timeout(function() { - updatingOWASPStatus = false; - updatingComodoStatus = false; - }, 100); - } else { if (response.data.owaspInstalled === 1) { @@ -1346,10 +1343,19 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) { } + // Always reset flags after status check completes + $timeout(function() { + updatingOWASPStatus = false; + updatingComodoStatus = false; + }, 100); + } function cantLoadInitialDatas(response) { $scope.modsecLoading = true; + // Reset flags even on error + updatingOWASPStatus = false; + updatingComodoStatus = false; } }