mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
new command 'set admin password'
This commit is contained in:
@@ -16,6 +16,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/).
|
|||||||
- CR11 thermostat [#2295](https://github.com/emsesp/EMS-ESP32/issues/2295)
|
- CR11 thermostat [#2295](https://github.com/emsesp/EMS-ESP32/issues/2295)
|
||||||
- Show ESP32's CPU temp in Hardware Status
|
- Show ESP32's CPU temp in Hardware Status
|
||||||
- vacation mode for the CR50 [#2403](https://github.com/emsesp/EMS-ESP32/issues/2403)
|
- vacation mode for the CR50 [#2403](https://github.com/emsesp/EMS-ESP32/issues/2403)
|
||||||
|
- new Console command "set admin password" to set WebUI admin password
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,40 @@ static void setup_commands(std::shared_ptr<Commands> const & commands) {
|
|||||||
//
|
//
|
||||||
// SET commands
|
// SET commands
|
||||||
//
|
//
|
||||||
|
commands->add_command(ShellContext::MAIN,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
string_vector{F_(set), F_(admin), F_(password)},
|
||||||
|
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
|
shell.enter_password(F_(new_password_prompt1), [](Shell & shell, bool completed, const std::string & password1) {
|
||||||
|
if (completed) {
|
||||||
|
shell.enter_password(F_(new_password_prompt2), [password1](Shell & shell, bool completed, const std::string & password2) {
|
||||||
|
if (completed) {
|
||||||
|
if (password1 == password2) {
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
EMSESP::esp32React.getSecuritySettingsService()->updateWithoutPropagation(
|
||||||
|
[&](SecuritySettings & securitySettings) {
|
||||||
|
// find the username 'admin' and update its password
|
||||||
|
for (auto & user : securitySettings.users) {
|
||||||
|
if (user.username == "admin") {
|
||||||
|
user.password = password2.c_str();
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// otherwise add a new admin user
|
||||||
|
securitySettings.users.emplace_back(F_(admin), password2.c_str(), true);
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
shell.println("Admin user's password updated.");
|
||||||
|
} else {
|
||||||
|
shell.println("Passwords do not match");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
commands->add_command(ShellContext::MAIN,
|
commands->add_command(ShellContext::MAIN,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
string_vector{F_(set), F_(wifi), F_(password)},
|
string_vector{F_(set), F_(wifi), F_(password)},
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ MAKE_WORD(show)
|
|||||||
MAKE_WORD(su)
|
MAKE_WORD(su)
|
||||||
MAKE_WORD(scan)
|
MAKE_WORD(scan)
|
||||||
MAKE_WORD(password)
|
MAKE_WORD(password)
|
||||||
|
MAKE_WORD(admin)
|
||||||
MAKE_WORD(read)
|
MAKE_WORD(read)
|
||||||
MAKE_WORD(values)
|
MAKE_WORD(values)
|
||||||
MAKE_WORD(system)
|
MAKE_WORD(system)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.7.2-dev.22"
|
#define EMSESP_APP_VERSION "3.7.3-dev.23"
|
||||||
|
|||||||
Reference in New Issue
Block a user