update multi_tenancy/license
This commit is contained in:
@@ -3,20 +3,26 @@ module MultiTenancy
|
||||
|
||||
included do
|
||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||
before_action :set_current_tenant_by_subdomain_or_first if respond_to? :before_action
|
||||
before_action :set_current_tenant_by_subdomain_or_name if respond_to? :before_action
|
||||
helper_method :current_shop if respond_to? :helper_method
|
||||
end
|
||||
|
||||
private
|
||||
def set_current_tenant_by_subdomain_or_first
|
||||
find_tenant_by_subdomain_or_frist || not_found
|
||||
def set_current_tenant_by_subdomain_or_name
|
||||
find_tenant_by_subdomain_or_name || not_found
|
||||
end
|
||||
|
||||
def find_tenant_by_subdomain_or_frist
|
||||
def find_tenant_by_subdomain_or_name
|
||||
if request.subdomains.last && request.subdomains.last != "www"
|
||||
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
|
||||
elsif ENV["SERVER_MODE"] == "application"
|
||||
set_current_tenant(Shop.first)
|
||||
license = License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
shop_name = license.read_license_no_decrypt("shop_name")
|
||||
if Rails.env.production? || shop_name
|
||||
set_current_tenant(Shop.find_by(name: shop_name))
|
||||
else
|
||||
set_current_tenant(Shop.first)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user