mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
fix export otp_key
This commit is contained in:
parent
2f686ca163
commit
7c24853e5e
2 changed files with 17 additions and 3 deletions
|
@ -509,7 +509,7 @@ class Cli
|
||||||
'password' => @mpw.get_password(item.id),
|
'password' => @mpw.get_password(item.id),
|
||||||
'protocol' => item.protocol,
|
'protocol' => item.protocol,
|
||||||
'port' => item.port,
|
'port' => item.port,
|
||||||
'otp_key' => @mpw.get_otp_code(item.id),
|
'otp_key' => @mpw.get_otp_key(item.id),
|
||||||
'comment' => item.comment,
|
'comment' => item.comment,
|
||||||
'last_edit' => item.last_edit,
|
'last_edit' => item.last_edit,
|
||||||
'created' => item.created,
|
'created' => item.created,
|
||||||
|
@ -521,7 +521,7 @@ class Cli
|
||||||
|
|
||||||
File.open(file, 'w') {|f| f << data.to_yaml}
|
File.open(file, 'w') {|f| f << data.to_yaml}
|
||||||
|
|
||||||
puts "#{I18n.t('export.export.valid', file)}".green
|
puts "#{I18n.t('export.valid', file)}".green
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "#{I18n.t('display.error')} #17: #{e}".red
|
puts "#{I18n.t('display.error')} #17: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
|
@ -403,9 +403,23 @@ class MPW
|
||||||
# args: id -> the item id
|
# args: id -> the item id
|
||||||
# key -> the new key
|
# key -> the new key
|
||||||
def set_otp_key(id, key)
|
def set_otp_key(id, key)
|
||||||
@otp_keys[id] = encrypt(key)
|
if not key.to_s.empty?
|
||||||
|
@otp_keys[id] = encrypt(key.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get an opt key
|
||||||
|
# args: id -> the item id
|
||||||
|
# key -> the new key
|
||||||
|
def get_otp_key(id)
|
||||||
|
if @otp_keys.has_key?(id)
|
||||||
|
return decrypt(@otp_keys[id])
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Get an otp code
|
# Get an otp code
|
||||||
# @args: id -> the item id
|
# @args: id -> the item id
|
||||||
# @rtrn: an otp code
|
# @rtrn: an otp code
|
||||||
|
|
Loading…
Add table
Reference in a new issue