Browse Source

Fix password menu stickiness before first auth (#21295)

ellensp 4 years ago
parent
commit
8857fc6c4b
No account linked to committer's email address

+ 7
- 4
Marlin/src/feature/password/password.cpp View File

@@ -31,7 +31,7 @@
31 31
 Password password;
32 32
 
33 33
 // public:
34
-bool     Password::is_set, Password::is_locked;
34
+bool     Password::is_set, Password::is_locked, Password::did_first_run; // = false
35 35
 uint32_t Password::value, Password::value_entry;
36 36
 
37 37
 //
@@ -47,11 +47,14 @@ void Password::lock_machine() {
47 47
 // Authentication check
48 48
 //
49 49
 void Password::authentication_check() {
50
-  if (value_entry == value)
50
+  if (value_entry == value) {
51 51
     is_locked = false;
52
-  else
52
+    did_first_run = true;
53
+  }
54
+  else {
55
+    is_locked = true;
53 56
     SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD);
54
-
57
+  }
55 58
   TERN_(HAS_LCD_MENU, authentication_done());
56 59
 }
57 60
 

+ 2
- 2
Marlin/src/feature/password/password.h View File

@@ -25,10 +25,10 @@
25 25
 
26 26
 class Password {
27 27
 public:
28
-  static bool is_set, is_locked;
28
+  static bool is_set, is_locked, did_first_run;
29 29
   static uint32_t value, value_entry;
30 30
 
31
-  Password() { is_locked = false; }
31
+  Password() {}
32 32
 
33 33
   static void lock_machine();
34 34
   static void authentication_check();

+ 9
- 4
Marlin/src/lcd/menu/menu_password.cpp View File

@@ -44,12 +44,18 @@ static uint8_t digit_no;
44 44
 // Screen for both editing and setting the password
45 45
 //
46 46
 void Password::menu_password_entry() {
47
+  ui.defer_status_screen(!did_first_run); // No timeout to status before first auth
48
+
47 49
   START_MENU();
48 50
 
49 51
   // "Login" or "New Code"
50 52
   STATIC_ITEM_P(authenticating ? GET_TEXT(MSG_LOGIN_REQUIRED) : GET_TEXT(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT);
51 53
 
52
-  STATIC_ITEM_P(NUL_STR, SS_CENTER|SS_INVERT, string);
54
+  STATIC_ITEM_P(NUL_STR, SS_CENTER, string);
55
+
56
+  #if HAS_MARLINUI_U8GLIB
57
+    STATIC_ITEM_P(NUL_STR, SS_CENTER, "");
58
+  #endif
53 59
 
54 60
   // Make the digit edit item look like a sub-menu
55 61
   PGM_P const label = GET_TEXT(MSG_ENTER_DIGIT);
@@ -57,7 +63,7 @@ void Password::menu_password_entry() {
57 63
   MENU_ITEM_ADDON_START(utf8_strlen_P(label) + 1);
58 64
     lcd_put_wchar(' ');
59 65
     lcd_put_wchar('1' + digit_no);
60
-    SETCURSOR_X(LCD_WIDTH - 1);
66
+    SETCURSOR_X(LCD_WIDTH - 2);
61 67
     lcd_put_wchar('>');
62 68
   MENU_ITEM_ADDON_END();
63 69
 
@@ -104,7 +110,7 @@ void Password::screen_password_entry() {
104 110
   value_entry = 0;
105 111
   digit_no = 0;
106 112
   editable.uint8 = 0;
107
-  memset(string, '-', PASSWORD_LENGTH);
113
+  memset(string, '_', PASSWORD_LENGTH);
108 114
   string[PASSWORD_LENGTH] = '\0';
109 115
   menu_password_entry();
110 116
 }
@@ -120,7 +126,6 @@ void Password::authenticate_user(const screenFunc_t in_succ_scr, const screenFun
120 126
   if (is_set) {
121 127
     authenticating = true;
122 128
     ui.goto_screen(screen_password_entry);
123
-    ui.defer_status_screen();
124 129
     ui.update();
125 130
   }
126 131
   else {

Loading…
Cancel
Save