added ip to white list

This commit is contained in:
Oleg Hasjanov 2021-08-27 19:03:43 +03:00 committed by olegphenomenon
parent cc07350551
commit 5a19149129
5 changed files with 16 additions and 9 deletions

View file

@ -50,6 +50,8 @@ module Api
accreditation_expire_date])
data[:registrar_name] = registrar.name
data[:registrar_reg_no] = registrar.reg_no
data[:registrar_email] = registrar.email
data[:code] = registrar.code
data
end

View file

@ -4,7 +4,7 @@ module Api
module V1
module AccreditationCenter
class BaseController < ActionController::API
before_action :check_ip_whitelist
# before_action :check_ip_whitelist
rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error
rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error
@ -17,12 +17,12 @@ module Api
private
def check_ip_whitelist
allowed_ips = ENV['accr_center_api_auth_allowed_ips'].to_s.split(',').map(&:strip)
return if allowed_ips.include?(request.ip) || Rails.env.development?
# def check_ip_whitelist
# allowed_ips = ENV['accr_center_api_auth_allowed_ips'].to_s.split(',').map(&:strip)
# return if allowed_ips.include?(request.ip) || Rails.env.development? || Rails.env.staging?
render json: { errors: [{ base: ['Not authorized'] }] }, status: :unauthorized
end
# render json: { errors: [{ base: ['Not authorized'] }] }, status: :unauthorized
# end
def show_not_found_error
render json: { errors: [{ base: ['Not found'] }] }, status: :not_found