1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

add attribute otp in item

This commit is contained in:
Adrien Waksberg 2016-10-17 18:34:43 +02:00
parent fc8e5e7115
commit aeae6e861c
2 changed files with 19 additions and 11 deletions

View file

@ -27,6 +27,7 @@ class Item
attr_accessor :protocol
attr_accessor :user
attr_accessor :port
attr_accessor :otp
attr_accessor :comment
attr_accessor :last_edit
attr_accessor :last_sync
@ -66,6 +67,7 @@ class Item
@protocol = options[:protocol] if options.has_key?(:protocol)
@user = options[:user] if options.has_key?(:user)
@port = options[:port].to_i if options.has_key?(:port) and not options[:port].to_s.empty?
@otp = options[:otp] if options.has_key?(:otp)
@comment = options[:comment] if options.has_key?(:comment)
@last_edit = Time.now.to_i if not options.has_key?(:no_update_last_edit)
end
@ -83,6 +85,7 @@ class Item
@protocol = nil
@user = nil
@port = nil
@otp = nil
@comment = nil
@created = nil
@last_edit = nil

View file

@ -88,6 +88,7 @@ class MPW
protocol: d['protocol'],
user: d['user'],
port: d['port'],
otp: @otp_keys.has_key?(d['id']),
comment: d['comment'],
last_edit: d['last_edit'],
created: d['created'],
@ -277,19 +278,23 @@ class MPW
# @args: file -> file where you export the data
def export(file)
data = {}
i = 1
@data.each do |item|
data.merge!("#{item.login}@#{item.host}" => {'group' => item.group,
'host' => item.host,
'protocol' => item.protocol,
'user' => item.user,
'password' => get_password(item.id),
'port' => item.port,
'comment' => item.comment,
'otp_key' => get_otp_code(item.id),
'last_edit' => item.last_edit,
'created' => item.created,
}
data.merge!(i => { 'group' => item.group,
'host' => item.host,
'protocol' => item.protocol,
'user' => item.user,
'password' => get_password(item.id),
'port' => item.port,
'comment' => item.comment,
'otp_key' => get_otp_code(item.id),
'last_edit' => item.last_edit,
'created' => item.created,
}
)
i += 1
end
File.open(file, 'w') {|f| f << data.to_yaml}