mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 18:32:37 +02:00
Fix ENABLE_AUTHENTICATION (#569)
* Fixed authentication code. * Removed another const cast Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
This commit is contained in:
@@ -592,8 +592,8 @@ namespace WebUI {
|
||||
String sadminPassword = admin_password->get();
|
||||
String suserPassword = user_password->get();
|
||||
|
||||
if (!((sUser == DEFAULT_ADMIN_LOGIN && sPassword == sadminPassword) ||
|
||||
(sUser == DEFAULT_USER_LOGIN && sPassword == suserPassword)) {
|
||||
if (!(sUser == DEFAULT_ADMIN_LOGIN && sPassword == sadminPassword) ||
|
||||
(sUser == DEFAULT_USER_LOGIN && sPassword == suserPassword)) {
|
||||
msg_alert_error = true;
|
||||
smsg = "Error: Incorrect password";
|
||||
code = 401;
|
||||
@@ -607,13 +607,19 @@ namespace WebUI {
|
||||
//change password
|
||||
if (_webserver->hasArg("PASSWORD") && _webserver->hasArg("USER") && _webserver->hasArg("NEWPASSWORD") &&
|
||||
(msg_alert_error == false)) {
|
||||
|
||||
String newpassword = _webserver->arg("NEWPASSWORD");
|
||||
if (COMMANDS::isLocalPasswordValid((char*)newpassword.c_str())) {
|
||||
|
||||
char pwdbuf[MAX_LOCAL_PASSWORD_LENGTH + 1];
|
||||
newpassword.toCharArray(pwdbuf, MAX_LOCAL_PASSWORD_LENGTH + 1);
|
||||
|
||||
if (COMMANDS::isLocalPasswordValid(pwdbuf)) {
|
||||
err_t err;
|
||||
|
||||
if (sUser == DEFAULT_ADMIN_LOGIN) {
|
||||
err = admin_password->setStringValue(newpassword);
|
||||
err = admin_password->setStringValue(pwdbuf);
|
||||
} else {
|
||||
err = user_password->setStringValue(newpassword);
|
||||
err = user_password->setStringValue(pwdbuf);
|
||||
}
|
||||
if (err) {
|
||||
msg_alert_error = true;
|
||||
|
Reference in New Issue
Block a user