mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-22 02:40:04 +00:00
add attribute otp in item
This commit is contained in:
parent
fc8e5e7115
commit
aeae6e861c
2 changed files with 19 additions and 11 deletions
|
@ -27,6 +27,7 @@ class Item
|
||||||
attr_accessor :protocol
|
attr_accessor :protocol
|
||||||
attr_accessor :user
|
attr_accessor :user
|
||||||
attr_accessor :port
|
attr_accessor :port
|
||||||
|
attr_accessor :otp
|
||||||
attr_accessor :comment
|
attr_accessor :comment
|
||||||
attr_accessor :last_edit
|
attr_accessor :last_edit
|
||||||
attr_accessor :last_sync
|
attr_accessor :last_sync
|
||||||
|
@ -66,6 +67,7 @@ class Item
|
||||||
@protocol = options[:protocol] if options.has_key?(:protocol)
|
@protocol = options[:protocol] if options.has_key?(:protocol)
|
||||||
@user = options[:user] if options.has_key?(:user)
|
@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?
|
@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)
|
@comment = options[:comment] if options.has_key?(:comment)
|
||||||
@last_edit = Time.now.to_i if not options.has_key?(:no_update_last_edit)
|
@last_edit = Time.now.to_i if not options.has_key?(:no_update_last_edit)
|
||||||
end
|
end
|
||||||
|
@ -83,6 +85,7 @@ class Item
|
||||||
@protocol = nil
|
@protocol = nil
|
||||||
@user = nil
|
@user = nil
|
||||||
@port = nil
|
@port = nil
|
||||||
|
@otp = nil
|
||||||
@comment = nil
|
@comment = nil
|
||||||
@created = nil
|
@created = nil
|
||||||
@last_edit = nil
|
@last_edit = nil
|
||||||
|
|
|
@ -88,6 +88,7 @@ class MPW
|
||||||
protocol: d['protocol'],
|
protocol: d['protocol'],
|
||||||
user: d['user'],
|
user: d['user'],
|
||||||
port: d['port'],
|
port: d['port'],
|
||||||
|
otp: @otp_keys.has_key?(d['id']),
|
||||||
comment: d['comment'],
|
comment: d['comment'],
|
||||||
last_edit: d['last_edit'],
|
last_edit: d['last_edit'],
|
||||||
created: d['created'],
|
created: d['created'],
|
||||||
|
@ -277,8 +278,10 @@ class MPW
|
||||||
# @args: file -> file where you export the data
|
# @args: file -> file where you export the data
|
||||||
def export(file)
|
def export(file)
|
||||||
data = {}
|
data = {}
|
||||||
|
i = 1
|
||||||
|
|
||||||
@data.each do |item|
|
@data.each do |item|
|
||||||
data.merge!("#{item.login}@#{item.host}" => {'group' => item.group,
|
data.merge!(i => { 'group' => item.group,
|
||||||
'host' => item.host,
|
'host' => item.host,
|
||||||
'protocol' => item.protocol,
|
'protocol' => item.protocol,
|
||||||
'user' => item.user,
|
'user' => item.user,
|
||||||
|
@ -290,6 +293,8 @@ class MPW
|
||||||
'created' => item.created,
|
'created' => item.created,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
i += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(file, 'w') {|f| f << data.to_yaml}
|
File.open(file, 'w') {|f| f << data.to_yaml}
|
||||||
|
|
Loading…
Add table
Reference in a new issue