mirror of https://github.com/arendst/Tasmota.git
Fix HTTP authorization response code
Fix HTTP authorization response code (#8170)
This commit is contained in:
parent
57f836cc9e
commit
97abf68612
|
@ -2562,17 +2562,20 @@ void HandleHttpCommand(void)
|
||||||
|
|
||||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND));
|
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND));
|
||||||
|
|
||||||
bool valid = true;
|
|
||||||
if (strlen(SettingsText(SET_WEBPWD))) {
|
if (strlen(SettingsText(SET_WEBPWD))) {
|
||||||
char tmp1[33];
|
char tmp1[33];
|
||||||
WebGetArg("user", tmp1, sizeof(tmp1));
|
WebGetArg("user", tmp1, sizeof(tmp1));
|
||||||
char tmp2[strlen(SettingsText(SET_WEBPWD)) +1];
|
char tmp2[strlen(SettingsText(SET_WEBPWD)) +1];
|
||||||
WebGetArg("password", tmp2, sizeof(tmp2));
|
WebGetArg("password", tmp2, sizeof(tmp2));
|
||||||
if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, SettingsText(SET_WEBPWD)))) { valid = false; }
|
if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, SettingsText(SET_WEBPWD)))) {
|
||||||
|
WSContentBegin(401, CT_JSON);
|
||||||
|
WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_NEED_USER_AND_PASSWORD "\"}"));
|
||||||
|
WSContentEnd();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WSContentBegin(200, CT_JSON);
|
WSContentBegin(200, CT_JSON);
|
||||||
if (valid) {
|
|
||||||
uint32_t curridx = web_log_index;
|
uint32_t curridx = web_log_index;
|
||||||
String svalue = Webserver->arg("cmnd");
|
String svalue = Webserver->arg("cmnd");
|
||||||
if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) {
|
if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) {
|
||||||
|
@ -2608,9 +2611,6 @@ void HandleHttpCommand(void)
|
||||||
} else {
|
} else {
|
||||||
WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_ENTER_COMMAND " cmnd=\"}"));
|
WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_ENTER_COMMAND " cmnd=\"}"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_NEED_USER_AND_PASSWORD "\"}"));
|
|
||||||
}
|
|
||||||
WSContentEnd();
|
WSContentEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue