1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-21 10:20:05 +00:00

add otp_key for import and export

This commit is contained in:
Adrien Waksberg 2016-08-20 16:09:34 +02:00
parent 973f362485
commit 126b896c24

View file

@ -287,6 +287,7 @@ class MPW
'password' => get_password(item.id), 'password' => get_password(item.id),
'port' => item.port, 'port' => item.port,
'comment' => item.comment, 'comment' => item.comment,
'otp_key' => get_otp_code(item.id),
'last_edit' => item.last_edit, 'last_edit' => item.last_edit,
'created' => item.created, 'created' => item.created,
} }
@ -314,7 +315,8 @@ class MPW
raise 'Item is empty' if item.empty? raise 'Item is empty' if item.empty?
@data.push(item) @data.push(item)
set_password(item.id, row['password']) set_password(item.id, row['password']) if not row['password'].to_s.empty?
set_otp_code(item.id, row['otp_key']) if not row['otp_key'].to_s.empty?
end end
rescue Exception => e rescue Exception => e
raise "#{I18n.t('error.import', file: file)}\n#{e}" raise "#{I18n.t('error.import', file: file)}\n#{e}"
@ -435,7 +437,7 @@ class MPW
# 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
def get_otp_code(id) def get_otp_code(id)
if not @otp_keys.has_key?(id) if not @otp_keys.has_key?(id)
return 0 return 0
else else