adding license

This commit is contained in:
Yan
2017-11-14 15:11:16 +06:30
parent a6252923f1
commit 683982d4f5
4 changed files with 35 additions and 26 deletions

View File

@@ -23,8 +23,8 @@ class ApplicationController < ActionController::Base
end
def lookup_domain
# if request.subdomain.present? && request.subdomain != "www"
@license = current_license(ENV["SX_PROVISION_URL"], "chromisreal-16") # request.subdomain.downcase
if request.subdomain.present? && request.subdomain != "www"
@license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase
if (!@license.nil?)
# logger.info "Location - " + @license.name
ActiveRecord::Base.establish_connection(website_connection(@license))
@@ -35,16 +35,17 @@ class ApplicationController < ActionController::Base
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
# end
end
end
def current_license(url, key)
@license = License.new(url, key)
##creating md5 hash
md5_hostname = Digest::MD5.new
md5key = md5_hostname.update(request.host)
if (@license.detail_with_local_cache(key, md5key.to_s) == true)
# Export for Key
passphrase = key + ENV["secret_key_base"]
key, iv = AESEncDec.export_key(passphrase)
if (@license.detail_with_local_file(key, key, iv) == true)
#if (@license.detail == true)
return @license