show users reports error if not admin

This commit is contained in:
proddy
2025-11-29 14:48:13 +01:00
parent 6569b8c038
commit a2baa50530
2 changed files with 7 additions and 2 deletions

View File

@@ -87,8 +87,8 @@ static void setup_commands(std::shared_ptr<Commands> const & commands) {
Command::show_all(shell);
} else if (command == F_(system)) {
EMSESP::system_.show_system(shell);
} else if (command == F_(users) && (shell.has_flags(CommandFlags::ADMIN))) {
EMSESP::system_.show_users(shell); // admin only
} else if (command == F_(users)) {
EMSESP::system_.show_users(shell);
} else if (command == F_(devices)) {
EMSESP::show_devices(shell);
} else if (command == F_(log)) {

View File

@@ -997,6 +997,11 @@ int8_t System::wifi_quality(int8_t dBm) {
// print users to console
void System::show_users(uuid::console::Shell & shell) {
if (!shell.has_flags(CommandFlags::ADMIN)) {
shell.printfln("Unauthorized. You need to be an admin to view users.");
return;
}
shell.printfln("Users:");
#ifndef EMSESP_STANDALONE