mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-06 16:27:12 +01:00
Unify admin passwords
This commit is contained in:
@@ -74,16 +74,13 @@
|
||||
#define WIFI_RECONNECT_INTERVAL 300000
|
||||
#define WIFI_MAX_NETWORKS 3
|
||||
#define ADMIN_PASS "fibonacci"
|
||||
#define AP_PASS ADMIN_PASS
|
||||
#define HTTP_USERNAME "admin"
|
||||
#define HTTP_PASSWORD ADMIN_PASS
|
||||
#define CSRF_BUFFER_SIZE 5
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// OTA & NOFUSS
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define OTA_PASS ADMIN_PASS
|
||||
#define OTA_PORT 8266
|
||||
#define NOFUSS_SERVER "http://192.168.1.100"
|
||||
#define NOFUSS_INTERVAL 3600000
|
||||
|
||||
@@ -13,11 +13,15 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
|
||||
// OTA
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void otaSetup() {
|
||||
|
||||
void otaConfigure() {
|
||||
ArduinoOTA.setPort(OTA_PORT);
|
||||
ArduinoOTA.setHostname(getSetting("hostname", HOSTNAME).c_str());
|
||||
ArduinoOTA.setPassword((const char *) OTA_PASS);
|
||||
ArduinoOTA.setPassword(getSetting("adminPass", ADMIN_PASS).c_str());
|
||||
}
|
||||
|
||||
void otaSetup() {
|
||||
|
||||
otaConfigure();
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
DEBUG_MSG("[OTA] Start\n");
|
||||
|
||||
@@ -93,7 +93,7 @@ void webSocketParse(uint32_t client_id, uint8_t * payload, size_t length) {
|
||||
#endif
|
||||
|
||||
// Do not change the password if empty
|
||||
if (key == "httpPassword") {
|
||||
if (key == "adminPass") {
|
||||
if (value.length() == 0) continue;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ void webSocketParse(uint32_t client_id, uint8_t * payload, size_t length) {
|
||||
|
||||
saveSettings();
|
||||
wifiConfigure();
|
||||
otaConfigure();
|
||||
buildTopics();
|
||||
|
||||
#if ENABLE_RF
|
||||
@@ -240,11 +241,10 @@ void webSocketEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsE
|
||||
// WEBSERVER
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void onHome(AsyncWebServerRequest *request){
|
||||
String password = getSetting("httpPassword", HTTP_PASSWORD);
|
||||
void onHome(AsyncWebServerRequest *request) {
|
||||
String password = getSetting("adminPass", ADMIN_PASS);
|
||||
char httpPassword[password.length() + 1];
|
||||
password.toCharArray(httpPassword, password.length() + 1);
|
||||
Serial.println(httpPassword);
|
||||
if (!request->authenticate(HTTP_USERNAME, httpPassword)) {
|
||||
return request->requestAuthentication();
|
||||
}
|
||||
|
||||
@@ -45,13 +45,13 @@ bool createAP() {
|
||||
|
||||
void wifiConfigure() {
|
||||
jw.scanNetworks(true);
|
||||
jw.setHostname((char *) getSetting("hostname", HOSTNAME).c_str());
|
||||
jw.setSoftAP((char *) getSetting("hostname", HOSTNAME).c_str(), (char *) AP_PASS);
|
||||
jw.setHostname(getSetting("hostname", HOSTNAME).c_str());
|
||||
jw.setSoftAP(getSetting("hostname", HOSTNAME).c_str(), getSetting("adminPass", ADMIN_PASS).c_str());
|
||||
jw.setAPMode(AP_MODE_ALONE);
|
||||
jw.cleanNetworks();
|
||||
if (getSetting("ssid0").length() > 0) jw.addNetwork((char *) getSetting("ssid0").c_str(), (char *) getSetting("pass0").c_str());
|
||||
if (getSetting("ssid1").length() > 0) jw.addNetwork((char *) getSetting("ssid1").c_str(), (char *) getSetting("pass1").c_str());
|
||||
if (getSetting("ssid2").length() > 0) jw.addNetwork((char *) getSetting("ssid2").c_str(), (char *) getSetting("pass2").c_str());
|
||||
if (getSetting("ssid0").length() > 0) jw.addNetwork(getSetting("ssid0").c_str(), getSetting("pass0").c_str());
|
||||
if (getSetting("ssid1").length() > 0) jw.addNetwork(getSetting("ssid1").c_str(), getSetting("pass1").c_str());
|
||||
if (getSetting("ssid2").length() > 0) jw.addNetwork(getSetting("ssid2").c_str(), getSetting("pass2").c_str());
|
||||
}
|
||||
|
||||
void wifiSetup() {
|
||||
@@ -110,6 +110,7 @@ void wifiSetup() {
|
||||
if (code == MESSAGE_ACCESSPOINT_CREATED) {
|
||||
DEBUG_MSG("[WIFI] MODE AP --------------------------------------\n");
|
||||
DEBUG_MSG("[WIFI] SSID %s\n", jw.getAPSSID().c_str());
|
||||
DEBUG_MSG("[WIFI] PASS %s\n", getSetting("adminPass", ADMIN_PASS).c_str());
|
||||
DEBUG_MSG("[WIFI] IP %s\n", WiFi.softAPIP().toString().c_str());
|
||||
DEBUG_MSG("[WIFI] MAC %s\n", WiFi.softAPmacAddress().c_str());
|
||||
DEBUG_MSG("[WIFI] ----------------------------------------------\n");
|
||||
|
||||
Reference in New Issue
Block a user