mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
add random password for update
This commit is contained in:
parent
e4fb780016
commit
6b8dce2eff
3 changed files with 16 additions and 13 deletions
|
@ -52,6 +52,10 @@ OptionParser.new do |opts|
|
|||
values[:pattern] = pattern
|
||||
end
|
||||
|
||||
opts.on('-r', '--random', I18n.t('option.random_password')) do
|
||||
options[:password] = true
|
||||
end
|
||||
|
||||
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
|
||||
options[:wallet] = wallet
|
||||
end
|
||||
|
@ -63,4 +67,4 @@ cli = MPW::Cli.new(config, options[:sync])
|
|||
cli.load_config
|
||||
cli.get_wallet(options[:wallet])
|
||||
cli.decrypt
|
||||
cli.update(values)
|
||||
cli.update(options[:password], values)
|
||||
|
|
|
@ -423,12 +423,9 @@ class Cli
|
|||
# Form to add a new item
|
||||
# @args: password -> generate a random password
|
||||
def add(password=false)
|
||||
options = text_editor('add_form', nil, password)
|
||||
item = Item.new(options)
|
||||
|
||||
if password
|
||||
options[:password] = MPW::password(@config.password)
|
||||
end
|
||||
options = text_editor('add_form', nil, password)
|
||||
item = Item.new(options)
|
||||
options[:password] = MPW::password(@config.password) if password
|
||||
|
||||
@mpw.add(item)
|
||||
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
||||
|
@ -442,8 +439,9 @@ class Cli
|
|||
end
|
||||
|
||||
# Update an item
|
||||
# @args: options -> the option to search
|
||||
def update(options={})
|
||||
# @args: password -> generate a random password
|
||||
# options -> the option to search
|
||||
def update(password=false, options={})
|
||||
items = @mpw.list(options)
|
||||
|
||||
if items.length == 0
|
||||
|
@ -451,8 +449,9 @@ class Cli
|
|||
else
|
||||
table_items(items) if items.length > 1
|
||||
|
||||
item = get_item(items)
|
||||
options = text_editor('update_form', item)
|
||||
item = get_item(items)
|
||||
options = text_editor('update_form', item, password)
|
||||
options[:password] = MPW::password(@config.password) if password
|
||||
|
||||
item.update(options)
|
||||
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# <%= I18n.t('form.update_item.host') %>
|
||||
host: <%= item.host %>
|
||||
# <%= I18n.t('form.update_item.login') %>
|
||||
user: <%= item.user %>
|
||||
user: <%= item.user %><% if not password %>
|
||||
# <%= I18n.t('form.update_item.password') %>
|
||||
password:
|
||||
password: <% end %>
|
||||
# <%= I18n.t('form.update_item.group') %>
|
||||
group: <%= item.group %>
|
||||
# <%= I18n.t('form.update_item.protocol') %>
|
||||
|
|
Loading…
Add table
Reference in a new issue