Skip to content

Commit f817cc6

Browse files
committed
Added reset_password variable in configuration.h and updated reset logic for password validation
1 parent 307aebe commit f817cc6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/config/Configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern tm timeinfo;
4848
// ============================================================================
4949

5050
// Data source and server settings
51+
extern char reset_password[33];
5152
extern char input_type[40];
5253
extern char ntp_server[40];
5354
extern char timezone[64];

src/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void setup(void) {
7777
html += "<h2>Reset Configuration?</h2>";
7878
html += "<p>Are you sure you want to reset the WiFi configuration? This will clear current WiFi settings and restart the device in AP mode.</p>";
7979
html += "<form method='POST' style='display:inline;' accept-charset='UTF-8'>";
80-
if (preferences.isKey("reset_password") && preferences.getString("reset_password").length() > 0) {
80+
if (reset_password != nullptr && String(reset_password).length() > 0) {
8181
html += "<input type='password' name='reset_password' placeholder='Enter reset password' required><br/>";
8282
}
8383
html += "<button type='submit' class='btn btn-yes'>Yes, Reset</button>";
@@ -88,10 +88,9 @@ void setup(void) {
8888
});
8989

9090
server.on("/reset", AsyncWebRequestMethod::HTTP_POST, [](AsyncWebServerRequest *request) {
91-
if (preferences.isKey("reset_password") && preferences.getString("reset_password").length() > 0) {
91+
if (reset_password != nullptr && String(reset_password).length() > 0) {
9292
if (request->hasParam("reset_password", true)) {
93-
String resetPassword = request->getParam("reset_password", true)->value();
94-
if (resetPassword == preferences.getString("reset_password")) {
93+
if (String(reset_password) == request->getParam("reset_password", true)->value()) {
9594
shouldResetConfig = true;
9695
request->send(200, "text/plain", "Resetting WiFi configuration, please log back into the hotspot to reconfigure...\r\n");
9796
} else {

0 commit comments

Comments
 (0)