@@ -20,26 +20,26 @@ ESP8266HTTPUpdateServer::ESP8266HTTPUpdateServer(bool serial_debug)
20
20
{
21
21
_serial_output = serial_debug;
22
22
_server = NULL ;
23
- _username = NULL ;
24
- _password = NULL ;
23
+ _username = emptyString ;
24
+ _password = emptyString ;
25
25
_authenticated = false ;
26
26
}
27
27
28
- void ESP8266HTTPUpdateServer::setup (ESP8266WebServer *server, const char * path, const char * username, const char * password)
28
+ void ESP8266HTTPUpdateServer::setup (ESP8266WebServer *server, const String& path, const String& username, const String& password)
29
29
{
30
30
_server = server;
31
- _username = ( char *) username;
32
- _password = ( char *) password;
31
+ _username = username;
32
+ _password = password;
33
33
34
34
// handler for the /update form page
35
- _server->on (path, HTTP_GET, [&](){
36
- if (_username != NULL && _password != NULL && !_server->authenticate (_username, _password))
35
+ _server->on (path. c_str () , HTTP_GET, [&](){
36
+ if (_username != emptyString && _password != emptyString && !_server->authenticate (_username. c_str () , _password. c_str () ))
37
37
return _server->requestAuthentication ();
38
38
_server->send_P (200 , PSTR (" text/html" ), serverIndex);
39
39
});
40
40
41
41
// handler for the /update form POST (once file upload finishes)
42
- _server->on (path, HTTP_POST, [&](){
42
+ _server->on (path. c_str () , HTTP_POST, [&](){
43
43
if (!_authenticated)
44
44
return _server->requestAuthentication ();
45
45
if (Update.hasError ()) {
@@ -61,7 +61,7 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path,
61
61
if (_serial_output)
62
62
Serial.setDebugOutput (true );
63
63
64
- _authenticated = (_username == NULL || _password == NULL || _server->authenticate (_username, _password));
64
+ _authenticated = (_username == emptyString || _password == emptyString || _server->authenticate (_username. c_str () , _password. c_str () ));
65
65
if (!_authenticated){
66
66
if (_serial_output)
67
67
Serial.printf (" Unauthenticated Update\n " );
0 commit comments