Skip to content

Commit 5f3c2e9

Browse files
committed
Fix Authentication flag not transmited in macro [ESP700]
Fix also doc for [ESP201] Thank you @Gi0cas
1 parent 1697f68 commit 5f3c2e9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

docs/Commands.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if authentication is on, need admin password
5454
[ESP114]
5555

5656
*Get/Set pin value
57-
[ESP201]P<pin> V<value> [PULLUP=YES RAW=YES]
57+
[ESP201]P<pin> V<value> [PULLUP=YES RAW=YES]pwd=<admin password>
5858
if no V<value> get P<pin> value
5959
if V<value> 0/1 set INPUT_PULLUP value, but for GPIO16 INPUT_PULLDOWN_16
6060
GPIO1 and GPIO3 cannot be used as they are used for serial

esp3d/command.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool COMMAND::isadmin(String & cmd_params)
9090
}
9191
adminpassword = get_param(cmd_params,"pwd=", true);
9292
if (!sadminPassword.equals(adminpassword)) {
93-
LOG("Not allowed\r\n")
93+
LOG("Not identified from command line\r\n")
9494
return false;
9595
} else {
9696
return true;
@@ -122,11 +122,28 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
122122
level_authenticate_type auth_type = auth_level;
123123
if (isadmin(cmd_params)) {
124124
auth_type = LEVEL_ADMIN;
125+
LOG("admin identified\r\n");
125126
}
126127
if (isuser(cmd_params) && (auth_type != LEVEL_ADMIN)) {
127128
auth_type = LEVEL_USER;
129+
LOG("user identified\r\n");
128130
}
129-
131+
#ifdef DEBUG_ESP3D
132+
if ( auth_type == LEVEL_ADMIN)
133+
{
134+
LOG("admin identified\r\n");
135+
}
136+
else {
137+
if( auth_type == LEVEL_USER)
138+
{
139+
LOG("user identified\r\n");
140+
}
141+
else
142+
{
143+
LOG("guest identified\r\n");
144+
}
145+
}
146+
#endif
130147
#endif
131148
//manage parameters
132149
byte mode = 254;
@@ -390,7 +407,7 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
390407
break;
391408
#ifdef DIRECT_PIN_FEATURE
392409
//Get/Set pin value
393-
//[ESP201]P<pin> V<value>
410+
//[ESP201]P<pin> V<value> [PULLUP=YES RAW=YES]pwd=<admin password>
394411
case 201:
395412
parameter = get_param(cmd_params,"", true);
396413
#ifdef AUTHENTICATION_FEATURE
@@ -1238,7 +1255,7 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
12381255
}
12391256
//if command is a valid number then execute command
12401257
if(cmd_part1.toInt()!=0) {
1241-
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE);
1258+
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE, auth_type);
12421259
}
12431260
//if not is not a valid [ESPXXX] command ignore it
12441261
}

0 commit comments

Comments
 (0)