mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +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
|
||||
|
|
|
@ -259,3 +259,7 @@ allow_accr_endspoints: 'true'
|
|||
whitelist_companies:
|
||||
- '12345678'
|
||||
- '87654321'
|
||||
|
||||
eeid_base_url: 'http://eid.test'
|
||||
ident_service_client_id: 123
|
||||
ident_service_client_secret: 321
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue