mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 05:47:53 +00:00
feat: no ask password if not necessary
This commit is contained in:
parent
1fcac965e9
commit
b83b27832e
1 changed files with 13 additions and 5 deletions
|
@ -126,12 +126,20 @@ module MPW
|
|||
|
||||
# Request the GPG password and decrypt the file
|
||||
def decrypt
|
||||
unless defined?(@mpw)
|
||||
@password = ask(I18n.t('display.gpg_password')) { |q| q.echo = false }
|
||||
@mpw = MPW.new(@config.gpg_key, @wallet_file, @password, @config.gpg_exe, @config.pinmode)
|
||||
end
|
||||
if defined?(@mpw)
|
||||
@mpw.read_data
|
||||
else
|
||||
begin
|
||||
@mpw = MPW.new(@config.gpg_key, @wallet_file, nil, @config.gpg_exe, @config.pinmode)
|
||||
|
||||
@mpw.read_data
|
||||
rescue
|
||||
@password = ask(I18n.t('display.gpg_password')) { |q| q.echo = false }
|
||||
@mpw = MPW.new(@config.gpg_key, @wallet_file, @password, @config.gpg_exe, @config.pinmode)
|
||||
|
||||
@mpw.read_data
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
puts "#{I18n.t('display.error')} #11: #{e}".red
|
||||
exit 2
|
||||
|
|
Loading…
Reference in a new issue