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

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

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

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

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

Loading…
Cancel
Save