Public Access
fix(nut-server): credentials passed by commands instead of args
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
1 file changed
+18
-1
@@ -397,7 +397,24 @@ void NutServerComponent::process_command(NutClient &client, const std::string &c
|
|||||||
|
|
||||||
void NutServerComponent::handle_login(NutClient &client, const std::string &args) {
|
void NutServerComponent::handle_login(NutClient &client, const std::string &args) {
|
||||||
auto parts = split_args(args);
|
auto parts = split_args(args);
|
||||||
if (parts.size() != 2) {
|
// client could already submitted login information through its correspondening commands
|
||||||
|
if (client.state == ClientState::AUTHENTICATED)
|
||||||
|
{
|
||||||
|
client.login_attempts++;
|
||||||
|
if (client.login_attempts >= MAX_LOGIN_ATTEMPTS)
|
||||||
|
{
|
||||||
|
ESP_LOGW(TAG, "Max login attempts exceeded, disconnecting client");
|
||||||
|
disconnect_client(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
send_response(client, "OK\n");
|
||||||
|
ESP_LOGD(TAG, "Client already connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// client isn't authenticated and did not provide any credentials
|
||||||
|
if (parts.size() != 2)
|
||||||
|
{
|
||||||
send_error(client, "INVALID-ARGUMENT");
|
send_error(client, "INVALID-ARGUMENT");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user