Class: Pwl::Commands::Passwd
Instance Method Summary collapse
Methods inherited from Base
default_locker_file, exit_codes_help
Instance Method Details
#call(args, options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 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 |
# File 'lib/pwl/commands/passwd.rb', line 4 def call(args, ) begin locker = open_locker() if !STDIN.tty? && !.gui # If we are in a pipe and do not run in GUI mode, we accept the new master password as args[0] new_master_password = args[0] begin validate!(new_master_password) rescue Pwl::InvalidMasterPasswordError => e exit_with(:validation_new_failed, .verbose, :message => e.) end else # If running interactively (console or gui), we loop until we get a valid password or break begin new_master_password = get_password("Enter the new master password for #{program(:name)}:", .gui) end while begin validate!(new_master_password) rescue Pwl::InvalidMasterPasswordError => e msg e. .gui || STDIN.tty? # only continue the loop when in interactive mode end # Confirm new password if new_master_password != get_password("Enter the new master password for #{program(:name)} again:", .gui) exit_with(:passwords_dont_match, .verbose) end end rescue Pwl::Dialog::Cancelled exit_with(:aborted, .verbose) end locker.change_password!(new_master_password) msg "Successfully changed master password for #{program(:name)}." if .verbose end |