1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

new syntax

This commit is contained in:
nishiki 2014-08-31 10:58:34 +02:00
parent 07f7aa5b67
commit 4a564dd07e

View file

@ -52,9 +52,10 @@ module MPW
client.puts delete_file(msg)
else
@log.warning("#{client.peeraddr[3]} is disconnected because unkwnow command")
send_msg = {:action => 'unknown',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.unknown'}
send_msg = {action: 'unknown',
gpg_key: msg['gpg_key'],
error: 'server.error.client.unknown'
}
client.puts send_msg
close_connection(client)
end
@ -87,20 +88,23 @@ module MPW
data = gpg_data['gpg']['data']
if is_authorized?(msg['password'], salt, hash)
send_msg = {:action => 'get',
:gpg_key => msg['gpg_key'],
:data => data,
:error => nil}
send_msg = {action: 'get',
gpg_key: msg['gpg_key'],
data: data,
error: nil
}
else
send_msg = {:action => 'get',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.no_authorized'}
send_msg = {action: 'get',
gpg_key: msg['gpg_key'],
error: 'server.error.client.no_authorized'
}
end
else
send_msg = {:action => 'get',
:gpg_key => msg['gpg_key'],
:data => '',
:error => nil}
send_msg = {action: 'get',
gpg_key: msg['gpg_key'],
data: '',
error: nil
}
end
return send_msg.to_json
@ -114,9 +118,10 @@ module MPW
data = msg['data']
if data.nil? || data.empty?
send_msg = {:action => 'update',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.no_data'}
send_msg = {action: 'update',
gpg_key: msg['gpg_key'],
error: 'server.error.client.no_data'
}
return send_msg.to_json
end
@ -141,24 +146,29 @@ module MPW
begin
config = {'gpg' => {'salt' => salt,
'hash' => hash,
'data' => data}}
'data' => data
}
}
File.open(file_gpg, 'w+') do |file|
file << config.to_yaml
end
send_msg = {:action => 'update',
:gpg_key => msg['gpg_key'],
:error => nil}
send_msg = {action: 'update',
gpg_key: msg['gpg_key'],
error: nil
}
rescue Exception => e
send_msg = {:action => 'update',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.unknown'}
send_msg = {action: 'update',
gpg_key: msg['gpg_key'],
error: 'server.error.client.unknown'
}
end
else
send_msg = {:action => 'update',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.no_authorized'}
send_msg = {action: 'update',
gpg_key: msg['gpg_key'],
error: 'server.error.client.no_authorized'
}
end
return send_msg.to_json
@ -192,18 +202,21 @@ module MPW
begin
File.unlink(file_gpg)
send_msg = {:action => 'delete',
:gpg_key => msg['gpg_key'],
:error => nil}
send_msg = {action: 'delete',
gpg_key: msg['gpg_key'],
error: nil
}
rescue Exception => e
send_msg = {:action => 'delete',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.unknown'}
send_msg = {action: 'delete',
gpg_key: msg['gpg_key'],
error: 'server.error.client.unknown'
}
end
else
send_msg = {:action => 'delete',
:gpg_key => msg['gpg_key'],
:error => 'server.error.client.no_authorized'}
send_msg = {action: 'delete',
gpg_key: msg['gpg_key'],
error: 'server.error.client.no_authorized'
}
end
return send_msg.to_json
@ -299,7 +312,9 @@ module MPW
'port' => port,
'data_dir' => data_dir,
'log_file' => log_file,
'timeout' => timeout}}
'timeout' => timeout
}
}
File.open(file_config, 'w') do |file|
file << config.to_yaml