Fix password menu stickiness before first auth (#21295)
This commit is contained in:
parent
f671e6d138
commit
8857fc6c4b
|
@ -31,7 +31,7 @@
|
|||
Password password;
|
||||
|
||||
// public:
|
||||
bool Password::is_set, Password::is_locked;
|
||||
bool Password::is_set, Password::is_locked, Password::did_first_run; // = false
|
||||
uint32_t Password::value, Password::value_entry;
|
||||
|
||||
//
|
||||
|
@ -47,11 +47,14 @@ void Password::lock_machine() {
|
|||
// Authentication check
|
||||
//
|
||||
void Password::authentication_check() {
|
||||
if (value_entry == value)
|
||||
if (value_entry == value) {
|
||||
is_locked = false;
|
||||
else
|
||||
did_first_run = true;
|
||||
}
|
||||
else {
|
||||
is_locked = true;
|
||||
SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD);
|
||||
|
||||
}
|
||||
TERN_(HAS_LCD_MENU, authentication_done());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
|
||||
class Password {
|
||||
public:
|
||||
static bool is_set, is_locked;
|
||||
static bool is_set, is_locked, did_first_run;
|
||||
static uint32_t value, value_entry;
|
||||
|
||||
Password() { is_locked = false; }
|
||||
Password() {}
|
||||
|
||||
static void lock_machine();
|
||||
static void authentication_check();
|
||||
|
|
|
@ -44,12 +44,18 @@ static uint8_t digit_no;
|
|||
// Screen for both editing and setting the password
|
||||
//
|
||||
void Password::menu_password_entry() {
|
||||
ui.defer_status_screen(!did_first_run); // No timeout to status before first auth
|
||||
|
||||
START_MENU();
|
||||
|
||||
// "Login" or "New Code"
|
||||
STATIC_ITEM_P(authenticating ? GET_TEXT(MSG_LOGIN_REQUIRED) : GET_TEXT(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT);
|
||||
|
||||
STATIC_ITEM_P(NUL_STR, SS_CENTER|SS_INVERT, string);
|
||||
STATIC_ITEM_P(NUL_STR, SS_CENTER, string);
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
STATIC_ITEM_P(NUL_STR, SS_CENTER, "");
|
||||
#endif
|
||||
|
||||
// Make the digit edit item look like a sub-menu
|
||||
PGM_P const label = GET_TEXT(MSG_ENTER_DIGIT);
|
||||
|
@ -57,7 +63,7 @@ void Password::menu_password_entry() {
|
|||
MENU_ITEM_ADDON_START(utf8_strlen_P(label) + 1);
|
||||
lcd_put_wchar(' ');
|
||||
lcd_put_wchar('1' + digit_no);
|
||||
SETCURSOR_X(LCD_WIDTH - 1);
|
||||
SETCURSOR_X(LCD_WIDTH - 2);
|
||||
lcd_put_wchar('>');
|
||||
MENU_ITEM_ADDON_END();
|
||||
|
||||
|
@ -104,7 +110,7 @@ void Password::screen_password_entry() {
|
|||
value_entry = 0;
|
||||
digit_no = 0;
|
||||
editable.uint8 = 0;
|
||||
memset(string, '-', PASSWORD_LENGTH);
|
||||
memset(string, '_', PASSWORD_LENGTH);
|
||||
string[PASSWORD_LENGTH] = '\0';
|
||||
menu_password_entry();
|
||||
}
|
||||
|
@ -120,7 +126,6 @@ void Password::authenticate_user(const screenFunc_t in_succ_scr, const screenFun
|
|||
if (is_set) {
|
||||
authenticating = true;
|
||||
ui.goto_screen(screen_password_entry);
|
||||
ui.defer_status_screen();
|
||||
ui.update();
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue