check subdomain
This commit is contained in:
@@ -39,17 +39,19 @@ class InstallController < BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lookup_domain
|
def lookup_domain
|
||||||
if (ENV["SERVER_MODE"] == "application") ||
|
if ENV["SERVER_MODE"] == "application"
|
||||||
(request.subdomain.present? && request.subdomain != "www" && ENV["SERVER_MODE"] != "cloud")
|
|
||||||
if check_license(request.host)
|
if check_license(request.host)
|
||||||
redirect_to root_url
|
redirect_to root_url and return
|
||||||
else
|
end
|
||||||
not_found unless check_subdomain(request.host)
|
elsif request.subdomains.last && request.subdomains.last != "www"
|
||||||
|
if check_license(request.host)
|
||||||
|
redirect_to root_url and return
|
||||||
|
elsif check_subdomain(request.host)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
not_found
|
not_found
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# def current_license(url, key)
|
# def current_license(url, key)
|
||||||
# @license = License.new(url, key)
|
# @license = License.new(url, key)
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class License
|
|||||||
aes = MyAesCrypt.new
|
aes = MyAesCrypt.new
|
||||||
aes_key, aes_iv = aes.export_key(lookup)
|
aes_key, aes_iv = aes.export_key(lookup)
|
||||||
|
|
||||||
params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} }
|
params = { query: { lookup_type: "cloud", lookup: lookup, iv_key: aes_iv} }
|
||||||
response = self.class.get("/subdomain", params)
|
response = self.class.get("/subdomain", params)
|
||||||
response.parsed_response["status"]
|
response.parsed_response["status"]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,23 +14,19 @@ class ActionController::Base
|
|||||||
def lookup_domain
|
def lookup_domain
|
||||||
if ENV["SERVER_MODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
if ENV["SERVER_MODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase
|
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # 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))
|
||||||
# authenticate_session_token
|
|
||||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
|
||||||
else
|
else
|
||||||
# reconnect_default_db
|
# reconnect_default_db
|
||||||
logger.info 'License is nil'
|
logger.info 'License is nil'
|
||||||
not_found
|
not_found
|
||||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
|
||||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
|
||||||
end
|
end
|
||||||
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
|
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
|
||||||
# check for license file
|
# check for license file
|
||||||
if check_license(request.host)
|
if check_license(request.host)
|
||||||
current_license(ENV["SX_PROVISION_URL"], request.host)
|
current_license(ENV["SX_PROVISION_URL"], request.host)
|
||||||
elsif check_subdomain(request.host)
|
elsif ENV["SERVER_MODE"] == "application" || check_subdomain(request.host)
|
||||||
redirect_to activate_path
|
redirect_to activate_path
|
||||||
else
|
else
|
||||||
not_found
|
not_found
|
||||||
@@ -122,14 +118,10 @@ class ActionController::API
|
|||||||
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))
|
||||||
# authenticate_session_token
|
|
||||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
|
||||||
else
|
else
|
||||||
# reconnect_default_db
|
# reconnect_default_db
|
||||||
logger.info 'License is nil'
|
logger.info 'License is nil'
|
||||||
not_found
|
not_found
|
||||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
|
||||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
|
||||||
end
|
end
|
||||||
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
|
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
|
||||||
not_found unless check_license(request.host)
|
not_found unless check_license(request.host)
|
||||||
|
|||||||
Reference in New Issue
Block a user