check subdomain

This commit is contained in:
Thein Lin Kyaw
2020-02-19 15:27:40 +06:30
parent 9605b8ce61
commit b207484735
3 changed files with 13 additions and 19 deletions

View File

@@ -14,23 +14,19 @@ 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?)
if !@license.nil?
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
not_found
# redirect_to root_url(:host => request.domain) + "store_error"
# render :json => [{ status: false, message: 'Invalid Access!'}]
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
if check_license(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
else
not_found
@@ -122,14 +118,10 @@ class ActionController::API
if (!@license.nil?)
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
not_found
# redirect_to root_url(:host => request.domain) + "store_error"
# render :json => [{ status: false, message: 'Invalid Access!'}]
end
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
not_found unless check_license(request.host)