mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 14:06:21 +02:00
Fixed codeclimate
This commit is contained in:
parent
637cabf95f
commit
285fa138e6
2 changed files with 11 additions and 2 deletions
|
@ -10,6 +10,7 @@ module Eeid
|
|||
rescue_from Shunter::ThrottleError, with: :handle_throttle_error
|
||||
|
||||
# POST /eeid/webhooks/identification_requests
|
||||
|
||||
def create
|
||||
return render_unauthorized unless ip_whitelisted?
|
||||
return render_invalid_signature unless valid_hmac_signature?(request.headers['X-HMAC-Signature'])
|
||||
|
@ -17,8 +18,7 @@ module Eeid
|
|||
verify_contact(permitted_params[:reference])
|
||||
render json: { status: 'success' }, status: :ok
|
||||
rescue StandardError => e
|
||||
Rails.logger.error("Error handling webhook: #{e.message}")
|
||||
render json: { error: 'Internal Server Error' }, status: :internal_server_error
|
||||
handle_error(e)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -64,6 +64,11 @@ module Eeid
|
|||
OpenStruct.new(id: request.remote_ip, class: 'WebhookRequest')
|
||||
end
|
||||
|
||||
def handle_error(error)
|
||||
Rails.logger.error("Error handling webhook: #{error.message}")
|
||||
render json: { error: 'Internal Server Error' }, status: :internal_server_error
|
||||
end
|
||||
|
||||
def handle_throttle_error
|
||||
render json: { error: Shunter.default_error_message }, status: :bad_request
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue