update multi tenancy

This commit is contained in:
Thein Lin Kyaw
2020-01-16 17:04:31 +06:30
parent b5e8bbec43
commit 87ad49a069
7 changed files with 28 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ class ActionController::Base
private
def lookup_domain
if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud"
if request.subdomain.present? && request.subdomain != "www" && ENV["SERVER_MODE"] == "cloud"
from = request.host
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
@@ -18,15 +18,20 @@ class ActionController::Base
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
elsif request.subdomain.present? && request.subdomain != "www" || ENV["SERVER_MODE"] == "application"
# check for license file
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
if check_license
current_license(ENV["SX_PROVISION_URL"])
else
redirect_to activate_path
end
else
render_not_found
end
end
def render_not_found
render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found
end
def current_license(url)
@@ -94,8 +99,8 @@ class ActionController::API
private
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
if request.subdomain.present? && request.subdomain != "www" && ENV["SERVER_CODE"] == "cloud"
from = request.host
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
logger.info "Location - " + @license.dbschema