Module: Lich::Common::GUI::MasterPasswordPrompt
- Defined in:
- documented/common/gui/master_password_prompt.rb
Class Method Summary collapse
-
.show_create_master_password_dialog ⇒ String?
Show the UI dialog to create a master password.
-
.show_enter_master_password_dialog(validation_test = nil) ⇒ String?
Show the UI dialog to enter a master password for recovery.
-
.show_warning_dialog(title, message) ⇒ Boolean
Show a warning dialog to the user.
-
.validate_master_password(master_password, validation_test) ⇒ Boolean
Validate the provided master password against a validation test.
Class Method Details
.show_create_master_password_dialog ⇒ String?
Show the UI dialog to create a master password. This method prompts the user to create a master password and validates its strength.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'documented/common/gui/master_password_prompt.rb', line 14 def self.show_create_master_password_dialog # Show UI dialog to user master_password = MasterPasswordPromptUI.show_dialog return nil if master_password.nil? # ==================================================================== # VALIDATION: Check password requirements # ==================================================================== if master_password.length < 8 if show_warning_dialog( "Short Password", "Password is shorter than 8 characters.\n" + "Longer passwords (12+ chars) are stronger.\n\n" + "Continue with this password?" ) # User chose to continue with weak password Lich.log "info: Master password strength validated (user override)" return master_password else # User declined weak password, restart Lich.log "info: User rejected weak password, prompting again" return show_create_master_password_dialog end end Lich.log "info: Master password strength validated" master_password end |
.show_enter_master_password_dialog(validation_test = nil) ⇒ String?
Show the UI dialog to enter a master password for recovery. This method prompts the user to enter their master password for recovery purposes.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'documented/common/gui/master_password_prompt.rb', line 51 def self.show_enter_master_password_dialog(validation_test = nil) # Show recovery UI dialog to user # Clearly indicates password recovery vs creation result = MasterPasswordPromptUI.show_recovery_dialog(validation_test) return nil if result.nil? Lich.log "info: Master password entered and validated for recovery" result end |
.show_warning_dialog(title, message) ⇒ Boolean
Show a warning dialog to the user. This method displays a modal dialog with a warning message and waits for user response.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'documented/common/gui/master_password_prompt.rb', line 83 def self.show_warning_dialog(title, ) # Block until dialog completes response = nil mutex = Mutex.new condition = ConditionVariable.new Gtk.queue do dialog = Gtk::MessageDialog.new( parent: nil, flags: :modal, type: :warning, buttons: :yes_no, message: title ) dialog.secondary_text = response = dialog.run dialog.destroy # Signal waiting thread mutex.synchronize { condition.signal } end # Wait for dialog to complete mutex.synchronize { condition.wait(mutex) } response == Gtk::ResponseType::YES end |
.validate_master_password(master_password, validation_test) ⇒ Boolean
Validate the provided master password against a validation test. This method checks if the given master password is valid based on the provided test.
70 71 72 73 74 |
# File 'documented/common/gui/master_password_prompt.rb', line 70 def self.validate_master_password(master_password, validation_test) return false if master_password.nil? || validation_test.nil? MasterPasswordManager.validate_master_password(master_password, validation_test) end |