Skip to content

Commit

Permalink
Improve relaxedSecurity handling
Browse files Browse the repository at this point in the history
  • Loading branch information
melkati committed Jun 9, 2024
1 parent 276d5b4 commit efabed4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extra_configs = platformio_extra_configs.ini
[version]
build_flags =
-D CO2_GADGET_VERSION="\"0.14."\"
-D CO2_GADGET_REV="\"005-development"\"
-D CO2_GADGET_REV="\"006-development"\"

;****************************************************************************************
;*** You can disable features by commenting the line with a semicolon at the beginning
Expand Down
1 change: 1 addition & 0 deletions webserver/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var forcedCaptivePortal = false;
var captivePortalNoTimeout = false;
var forcedCaptivePortalNoTimeout = false;
var relaxedSecurity = false; // Flag to control relaxed security mode
var forcedRelaxedSecurity = false; // Enadled by url parameter "relaxedSecurity"

// Global variable to control captive portal test mode
var forceCaptivePortalActive = false; // Flag to indicate url parameters include "forceCaptivePortalActive"
Expand Down
10 changes: 8 additions & 2 deletions webserver/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ function fetchVersion() {
function populateFormWithPreferences(preferences) {
// Update relaxedSecurity if present in data
if (preferences.relaxedSecurity !== undefined) {
if (preferencesDebug) console.log(`Setting relaxedSecurity to:`, preferences.relaxedSecurity);
if (preferencesDebug) console.log(`Setting relaxedSecurity field to:`, preferences.relaxedSecurity);
// If forcedRelaxedSecurity is set because the current URL does contains the "relaxedSecurity" parameter, do not overide the value with the one from the server
if (!forcedRelaxedSecurity) {
relaxedSecurity = preferences.relaxedSecurity;
}
}

handlePasswordFields();
Expand Down Expand Up @@ -460,10 +463,12 @@ function handlePasswordFields() {
passwordFields.forEach(field => {
if (relaxedSecurity) {
field.removeAttribute('disabled');
if (preferencesDebug) console.log(`Field ${field.id} enabled`);
} else {
field.disabled = true;
field.value = '';
field.placeholder = "Password (disabled)";
if (preferencesDebug) console.log(`Field ${field.id} disabled`);
}
});

Expand Down Expand Up @@ -600,7 +605,8 @@ document.addEventListener("DOMContentLoaded", () => {
// Check if the current URL contains "preferences.html"
if (currentURL.includes("preferences.html")) {
highlightCurrentPage(); // Highlight the current page in the navigation bar
relaxedSecurity = currentURL.includes("relaxedSecurity");
forcedRelaxedSecurity = currentURL.includes("relaxedSecurity");
relaxedSecurity = forcedRelaxedSecurity;
forceCaptivePortalActive = currentURL.includes("forceCaptivePortalActive");
handlePasswordFields();
setTimeout(() => { loadPreferencesFromServer(); }, 50); // Delay of 100ms
Expand Down

0 comments on commit efabed4

Please sign in to comment.