diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index 108c4104..7c264f83 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -3,7 +3,7 @@ class Api::ShopsController < Api::ApiController skip_before_action :set_current_tenant_by_subdomain_or_name, only: [:index, :show] def index - @shops = Shop.select('id, logo, name, shop_code').all + @shops = Shop.select('id, logo, name, shop_code').where.not(cloud_url: nil).all end def show @@ -13,4 +13,23 @@ class Api::ShopsController < Api::ApiController def get_tax_profiles @inclusive_tax, @exclusive_tax = TaxProfile.calculate_tax("online_order") end + + def lookup_domain + if ["index", "show"].include? action_name + if ENV["SERVER_CODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www" + @license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase + if (!@license.nil?) + logger.info "Location - " + @license.dbschema + ActiveRecord::Base.establish_connection(website_connection(@license)) + else + logger.info 'License is nil' + not_found + end + elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www") + not_found unless check_license(request.host) + end + else + super + end + end end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 8931f599..7ab4c8fd 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -132,9 +132,7 @@ class ActionController::API # render :json => [{ status: false, message: 'Invalid Access!'}] end elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www") - unless check_license(request.host) - not_found - end + not_found unless check_license(request.host) else not_found end