Commit aeacb867 authored by Eric Duminil's avatar Eric Duminil
Browse files

No need to ask for password twice

parent 80e074fa
Pipeline #5816 passed with stage
in 2 minutes and 41 seconds
......@@ -169,9 +169,13 @@ namespace web_server {
web_config::http.on("/delete_csv", HTTP_POST, handleDeleteCSV);
}
// Allow access if http_user or http_password are empty, or if provided credentials match
/*
* Allow access if Ampel is in access point mode,
* if http_user or http_password are empty,
* or if provided credentials match
*/
bool shouldBeAllowed() {
return strcmp(config::http_user, "") == 0 || strcmp(config::ap_password(), "") == 0
return wifi::isAccessPoint() || strcmp(config::http_user, "") == 0 || strcmp(config::ap_password(), "") == 0
|| web_config::http.authenticate(config::http_user, config::ap_password());
}
......@@ -210,9 +214,10 @@ namespace web_server {
lorawan::connected ? "Yes" : "No", config::lorawan_frequency_plan, lorawan::last_transmission,
config::lorawan_sending_interval,
#endif
config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", config::ampel_name(), config::ampel_name(),
wifi::local_ip, wifi::local_ip, ampel.macAddress, ESP.getFreeHeap(), esp_get_max_free_block_size(),
esp_get_heap_fragmentation(), ampel.max_loop_duration, ampel.board, ampel.sensorId, ampel.version, dd, hh, mm, ss);
config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", config::ampel_name(),
config::ampel_name(), wifi::local_ip, wifi::local_ip, ampel.macAddress, ESP.getFreeHeap(),
esp_get_max_free_block_size(), esp_get_heap_fragmentation(), ampel.max_loop_duration, ampel.board,
ampel.sensorId, ampel.version, dd, hh, mm, ss);
Serial.print(F(" - Body size : "));
Serial.print(strlen(content));
......
......@@ -19,6 +19,10 @@ namespace wifi {
return WiFi.status() == WL_CONNECTED;
}
bool isAccessPoint() {
return WiFi.getMode() == WIFI_AP;
}
/*
* Connection attempt, called in blocking mode by setup(). This way, LED effects can be shown
* without needing callbacks, but only during wifi_timeout seconds.
......@@ -31,7 +35,7 @@ namespace wifi {
void tryConnection() {
for (int i = 0; i <= config::wifi_timeout + 5; i++) {
web_config::update();
if (WiFi.getMode() == WIFI_AP){
if (isAccessPoint()) {
led_effects::alert(0x1cff68);
} else if (connected()) {
break;
......
......@@ -5,6 +5,7 @@ namespace wifi {
extern char local_ip[16];
void defineCommands();
bool connected();
bool isAccessPoint();
void tryConnection();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment