feat(poc): Disable widget based on country (#6658)
This commit is contained in:
14
enterprise/app/controllers/enterprise/widgets_controller.rb
Normal file
14
enterprise/app/controllers/enterprise/widgets_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Enterprise::WidgetsController
|
||||
private
|
||||
|
||||
def ensure_location_is_supported
|
||||
countries = @web_widget.inbox.account.custom_attributes['allowed_countries']
|
||||
return if countries.blank?
|
||||
|
||||
geocoder_result = IpLookupService.new.perform(request.remote_ip)
|
||||
return unless geocoder_result
|
||||
|
||||
country_enabled = countries.include?(geocoder_result.country_code)
|
||||
render json: { error: 'Location is not supported' }, status: :unauthorized unless country_enabled
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user