mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +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
|
values[:pattern] = pattern
|
||||||
end
|
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|
|
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
|
||||||
options[:wallet] = wallet
|
options[:wallet] = wallet
|
||||||
end
|
end
|
||||||
|
@ -63,4 +67,4 @@ cli = MPW::Cli.new(config, options[:sync])
|
||||||
cli.load_config
|
cli.load_config
|
||||||
cli.get_wallet(options[:wallet])
|
cli.get_wallet(options[:wallet])
|
||||||
cli.decrypt
|
cli.decrypt
|
||||||
cli.update(values)
|
cli.update(options[:password], values)
|
||||||
|
|
|
@ -423,12 +423,9 @@ class Cli
|
||||||
# Form to add a new item
|
# Form to add a new item
|
||||||
# @args: password -> generate a random password
|
# @args: password -> generate a random password
|
||||||
def add(password=false)
|
def add(password=false)
|
||||||
options = text_editor('add_form', nil, password)
|
options = text_editor('add_form', nil, password)
|
||||||
item = Item.new(options)
|
item = Item.new(options)
|
||||||
|
options[:password] = MPW::password(@config.password) if password
|
||||||
if password
|
|
||||||
options[:password] = MPW::password(@config.password)
|
|
||||||
end
|
|
||||||
|
|
||||||
@mpw.add(item)
|
@mpw.add(item)
|
||||||
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
||||||
|
@ -442,8 +439,9 @@ class Cli
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update an item
|
# Update an item
|
||||||
# @args: options -> the option to search
|
# @args: password -> generate a random password
|
||||||
def update(options={})
|
# options -> the option to search
|
||||||
|
def update(password=false, options={})
|
||||||
items = @mpw.list(options)
|
items = @mpw.list(options)
|
||||||
|
|
||||||
if items.length == 0
|
if items.length == 0
|
||||||
|
@ -451,8 +449,9 @@ class Cli
|
||||||
else
|
else
|
||||||
table_items(items) if items.length > 1
|
table_items(items) if items.length > 1
|
||||||
|
|
||||||
item = get_item(items)
|
item = get_item(items)
|
||||||
options = text_editor('update_form', item)
|
options = text_editor('update_form', item, password)
|
||||||
|
options[:password] = MPW::password(@config.password) if password
|
||||||
|
|
||||||
item.update(options)
|
item.update(options)
|
||||||
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
@mpw.set_password(item.id, options[:password]) if options.has_key?(:password)
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
# <%= I18n.t('form.update_item.host') %>
|
# <%= I18n.t('form.update_item.host') %>
|
||||||
host: <%= item.host %>
|
host: <%= item.host %>
|
||||||
# <%= I18n.t('form.update_item.login') %>
|
# <%= I18n.t('form.update_item.login') %>
|
||||||
user: <%= item.user %>
|
user: <%= item.user %><% if not password %>
|
||||||
# <%= I18n.t('form.update_item.password') %>
|
# <%= I18n.t('form.update_item.password') %>
|
||||||
password:
|
password: <% end %>
|
||||||
# <%= I18n.t('form.update_item.group') %>
|
# <%= I18n.t('form.update_item.group') %>
|
||||||
group: <%= item.group %>
|
group: <%= item.group %>
|
||||||
# <%= I18n.t('form.update_item.protocol') %>
|
# <%= I18n.t('form.update_item.protocol') %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue