fix licnese
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
class ActionController::Base
|
class ActionController::Base
|
||||||
before_action :lookup_domain, :set_locale
|
before_action :lookup_domain if Rails.env.production?
|
||||||
|
before_action :set_locale
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def lookup_domain
|
def lookup_domain
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_MODE"] == "cloud"
|
||||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
|
||||||
if (!@license.nil?)
|
if (!@license.nil?)
|
||||||
logger.info "Location - " + @license.dbschema
|
logger.info "Location - " + @license.dbschema
|
||||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
@@ -18,26 +18,34 @@ class ActionController::Base
|
|||||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||||
end
|
end
|
||||||
else
|
elsif request.subdomains.last && request.subdomains.last != "www" || ENV["SERVER_MODE"] == "application"
|
||||||
# check for license file
|
# check for license file
|
||||||
if check_license
|
if check_license(request.host)
|
||||||
current_license(ENV["SX_PROVISION_URL"])
|
current_license(ENV["SX_PROVISION_URL"], request.host)
|
||||||
else
|
else
|
||||||
redirect_to activate_path
|
redirect_to activate_path
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_license(url)
|
def not_found
|
||||||
@license = License.new(url)
|
respond_to do |format|
|
||||||
|
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
|
||||||
|
format.json { head :not_found }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_license(url, lookup)
|
||||||
|
@license = License.new(url, lookup)
|
||||||
flag = @license.detail_with_local_file()
|
flag = @license.detail_with_local_file()
|
||||||
if (flag == 0)
|
if (flag == 0)
|
||||||
flash[:notice] = 'Expired or No License!'
|
flash[:notice] = 'Expired or No License!'
|
||||||
elsif (flag == 2)
|
elsif (flag == 2)
|
||||||
flash[:notice] = 'Expiring! Please, License extend...'
|
flash[:notice] = 'Expiring! Please, License extend...'
|
||||||
else
|
else
|
||||||
puts "RUN SAY BYAR"
|
Rails.logger.info "Run License"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,8 +59,8 @@ class ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_license
|
def check_license(lookup)
|
||||||
License.check_license_file
|
License.check_license_file(lookup)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_installation
|
def check_installation
|
||||||
@@ -89,14 +97,13 @@ class ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
class ActionController::API
|
class ActionController::API
|
||||||
before_action :lookup_domain
|
before_action :lookup_domain if Rails.env.production?
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def lookup_domain
|
def lookup_domain
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] == "cloud"
|
||||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
|
||||||
if (!@license.nil?)
|
if (!@license.nil?)
|
||||||
logger.info "Location - " + @license.dbschema
|
logger.info "Location - " + @license.dbschema
|
||||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
|
|||||||
Reference in New Issue
Block a user