Merge branch 'r-1902001-01' into foodcourt
This commit is contained in:
@@ -2,6 +2,8 @@ class ActionController::Base
|
||||
before_action :lookup_domain if Rails.env.production?
|
||||
before_action :set_locale
|
||||
|
||||
helper_method :current_license,
|
||||
|
||||
def not_found
|
||||
respond_to do |format|
|
||||
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
|
||||
@@ -13,10 +15,9 @@ class ActionController::Base
|
||||
|
||||
def lookup_domain
|
||||
if ENV["SERVER_MODE"] == "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))
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
@@ -24,47 +25,30 @@ class ActionController::Base
|
||||
end
|
||||
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
|
||||
# check for license file
|
||||
if check_license(request.host)
|
||||
current_license(ENV["SX_PROVISION_URL"], request.host)
|
||||
elsif ENV["SERVER_MODE"] == "application" || check_subdomain(request.host)
|
||||
if !current_license.exists?
|
||||
redirect_to activate_path
|
||||
else
|
||||
not_found
|
||||
elsif current_license.expired?
|
||||
redirect_to review_license_path
|
||||
end
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
Rails.logger.info "Run License"
|
||||
end
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def check_subdomain(lookup)
|
||||
license = License.new(ENV["SX_PROVISION_URL"], lookup)
|
||||
license.check_license_subdomain(lookup)
|
||||
end
|
||||
|
||||
def check_license(lookup)
|
||||
License.check_license_file(lookup)
|
||||
def check_subdomain
|
||||
current_license.check_license_subdomain
|
||||
end
|
||||
|
||||
def check_installation
|
||||
@@ -76,7 +60,6 @@ class ActionController::Base
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
@@ -114,27 +97,28 @@ class ActionController::API
|
||||
|
||||
def lookup_domain
|
||||
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))
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
else
|
||||
# reconnect_default_db
|
||||
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)
|
||||
not_found unless current_license.exists? && !current_license.expired?
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
@@ -147,7 +131,6 @@ class ActionController::API
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
|
||||
Reference in New Issue
Block a user