licensing
This commit is contained in:
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
# lookup domain for db from provision
|
||||
before_action :check_license, :lookup_domain, :set_locale
|
||||
before_action :lookup_domain, :set_locale
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
# alias_method :current_user, :current_login_employee,:current_user
|
||||
@@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
@license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase
|
||||
@license = cache_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,30 +35,32 @@ class ApplicationController < ActionController::Base
|
||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license()
|
||||
@license = License.new(url, subdomain)
|
||||
##creating md5 hash
|
||||
md5_hostname = Digest::MD5.new
|
||||
md5key = md5_hostname.update(request.host)
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
|
||||
if (@license.detail_with_local_cache(subdomain, md5key.to_s) == true)
|
||||
if (@license.detail_with_local_file(lookup) == true)
|
||||
return @license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url, key)
|
||||
@license = License.new(url, key)
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
|
||||
# Export for Key
|
||||
passphrase = key + ENV["secret_key_base"]
|
||||
key, iv = AESEncDec.export_key(passphrase)
|
||||
# Export for Key
|
||||
aes = AesCrypt.new
|
||||
aes_key, aes_iv = aes.export_key(lookup)
|
||||
|
||||
if (@license.detail_with_local_file(key, key, iv) == true)
|
||||
if (@license.detail_with_local_cache(lookup, aes_key, aes_iv) == true)
|
||||
return @license
|
||||
else
|
||||
return nil
|
||||
@@ -107,9 +109,7 @@ class ApplicationController < ActionController::Base
|
||||
private
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
# if !License.check_license_valid
|
||||
# redirect_to install_path
|
||||
# end
|
||||
return true
|
||||
else
|
||||
redirect_to install_path
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user