mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Move SSID/Password to common image
This commit is contained in:
parent
f9109d0348
commit
96016579aa
3 changed files with 28 additions and 66 deletions
|
@ -506,6 +506,10 @@ void init_webserver() {
|
|||
} else if (p->name() == "SUBNET4") {
|
||||
auto type = atoi(p->value().c_str());
|
||||
settings.saveUInt("SUBNET4", type);
|
||||
} else if (p->name() == "SSID") {
|
||||
settings.saveString("SSID", p->value().c_str());
|
||||
} else if (p->name() == "PASSWORD") {
|
||||
settings.saveString("PASSWORD", p->value().c_str());
|
||||
} else if (p->name() == "APNAME") {
|
||||
settings.saveString("APNAME", p->value().c_str());
|
||||
} else if (p->name() == "APPASSWORD") {
|
||||
|
@ -602,37 +606,6 @@ void init_webserver() {
|
|||
request->redirect("/settings");
|
||||
});
|
||||
|
||||
// Route for editing SSID
|
||||
def_route_with_auth("/updateSSID", server, HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
if (request->hasParam("value")) {
|
||||
String value = request->getParam("value")->value();
|
||||
if (value.length() <= 63) { // Check if SSID is within the allowable length
|
||||
ssid = value.c_str();
|
||||
store_settings();
|
||||
request->send(200, "text/plain", "Updated successfully");
|
||||
} else {
|
||||
request->send(400, "text/plain", "SSID must be 63 characters or less");
|
||||
}
|
||||
} else {
|
||||
request->send(400, "text/plain", "Bad Request");
|
||||
}
|
||||
});
|
||||
// Route for editing Password
|
||||
def_route_with_auth("/updatePassword", server, HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
if (request->hasParam("value")) {
|
||||
String value = request->getParam("value")->value();
|
||||
if (value.length() >= 8) { // Password must be 8 characters or longer
|
||||
password = value.c_str();
|
||||
store_settings();
|
||||
request->send(200, "text/plain", "Updated successfully");
|
||||
} else {
|
||||
request->send(400, "text/plain", "Password must be atleast 8 characters");
|
||||
}
|
||||
} else {
|
||||
request->send(400, "text/plain", "Bad Request");
|
||||
}
|
||||
});
|
||||
|
||||
auto update_string = [](const char* route, std::function<void(String)> setter,
|
||||
std::function<bool(String)> validator = nullptr) {
|
||||
def_route_with_auth(route, server, HTTP_GET, [=](AsyncWebServerRequest* request) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue