Comments (3)
request->requestAuthentication();
on authenticated user will clear the authentication from the browser
from espasyncwebserver.
Works thanks 👍
from espasyncwebserver.
How does it work ?
How can you turn this OFF ?
I have a LOGIN and a SKIP button inside a HTML page.
This is the LOGIN:
server.on("/register", HTTP_POST, [](AsyncWebServerRequest * request){
int params = request->params();
String values_user[2];
for(int i=0;i<params;i++){
AsyncWebParameter* p = request->getParam(i);
if(p->isPost()){
logOutput((String)"POST[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
values_user[i] = p->value();
} else {
logOutput((String)"GET[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
}
} // for(int i=0;i<params;i++)
if(values_user[0] != NULL && values_user[0].length() != 0 &&
values_user[1] != NULL && values_user[1].length() != 0) {
File userWrite = SPIFFS.open("/user.txt", FILE_WRITE);
if(!userWrite) logOutput((String)"ERROR_INSIDE_POST ! Couldn't open file to write USER credentials !");
userWrite.println(values_user[0]); // Username
userWrite.println(values_user[1]); // Password
userWrite.close();
logOutput("Username and password saved !");
request->redirect("/config");
// digitalWrite(LED, LOW);
} else request->redirect("/register");
});
And this is the SKIP:
server.on("/button", HTTP_POST, [](AsyncWebServerRequest * request){
int params = request->params();
String values_button = "";
for(int i=0;i<params;i++){
AsyncWebParameter* p = request->getParam(i);
if(p->isPost()){
logOutput((String)"POST[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
values_button = p->value();
} else {
logOutput((String)"GET[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
}
} // for(int i=0;i<params;i++)
values_button.trim();
if(values_button == "Skip") {
request->requestAuthentication(); // this doesn't change a thing
}
request->redirect("/config");
});
This is the "/config" :
server.on("/config", HTTP_GET, [](AsyncWebServerRequest *request){
if(!request->authenticate(http_username, http_password))
return request->requestAuthentication();
request->send(SPIFFS, "/STA_configPage.html", "text/html");
});
If I press SKIP it redirects me to config but still asks for a username and password.
from espasyncwebserver.
Related Issues (20)
- fragmentation
- ESP8266 goin down when get JSON string. HOT 1
- where i can get request if i mast send JSON to all connected clients by timer ?! no good exapmles no information! HOT 2
- Serving SPIFFS from a subdirectory raises 500 status code on some files HOT 1
- error: cannot bind non-const lvalue reference of type 'ArduinoJson::V704PB2::JsonObject&' to an rvalue of type 'ArduinoJson::V704PB2::detail::enable_if<true, ArduinoJson::V704PB2::JsonObject>::type' {aka 'ArduinoJson::V704PB2::JsonObject'} HOT 1
- abracadabra in serial HOT 1
- after long time 8+ i have spam in serial
- AsyncWebServerRequest Questions HOT 2
- Send content with beginChunkedResponse
- Question: is it possible to replicate AsyncWebSocket with WebServer in arduino-esp32 v3.0.0 ? HOT 4
- AsyncWebServer Questions HOT 6
- Images won't load randomly
- Compiling issues HOT 7
- I Can't make the web explorer to offer to save credentials
- Change bool AsyncStaticWebHandler::canHandle to use exact match instead of String::startsWith(_uri)
- small ddos (press F5) crash: async_tcp ....watchdog got triggered
- Compilation Error for Newer ESP32 HOT 3
- possible memory leak at send_p?
- Forwarding Webserver with websockets
- Get new client ID at every refresh :( HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espasyncwebserver.