mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
[enh] add better error management
This commit is contained in:
parent
7662757275
commit
41e2e480bb
1 changed files with 11 additions and 0 deletions
11
dynette.rb
11
dynette.rb
|
@ -222,6 +222,17 @@ put '/migrate_key_to_sha512/' do
|
|||
entry.public_key = params[:public_key_sha512]
|
||||
entry.key_algo = "hmac-sha512"
|
||||
|
||||
# we probably want to remove this once this algo is stable to avoid having
|
||||
# an entry point in our api where some could possibly hammer our db to try
|
||||
# to find if a key is registered or not
|
||||
if entry == nil
|
||||
if Entry.first(:public_key => params[:public_key_sha512])
|
||||
halt 400, { :error => "This domain has already been migrated to hmac-sha512." }.to_json
|
||||
else
|
||||
halt 404, { :error => "There is not domain registered with this key." }.to_json
|
||||
end
|
||||
end
|
||||
|
||||
unless entry.save
|
||||
halt 412, { :error => "A problem occured during key algo migration" }.to_json
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue