From 308e007372dab5c05bfc55b6126aec08e6bae3d3 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 8 Dec 2017 11:51:38 +0630 Subject: [PATCH] license updating --- app/controllers/application_controller.rb | 17 +++-------------- app/models/license.rb | 13 ++++++++++++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3b7539a8..6f754591 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -55,21 +55,10 @@ class ApplicationController < ActionController::Base end end - def cache_license(url, lookup) - flag = ENV["AES_IV"] - @license = License.new(url, lookup) + def cache_license(url, lookup) + @license = License.new(url, lookup) - # Check Exists IV - if flag == "<%= ENV['AES_IV'] %>" - # Export for Key - aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(lookup) - else - aes_key = ENV["AES_KEY"] - aes_iv = ENV["AES_IV"] - end - - if (@license.detail_with_local_cache(lookup, aes_key, aes_iv) == true) + if (@license.detail_with_local_cache(lookup) == true) return @license else return nil diff --git a/app/models/license.rb b/app/models/license.rb index d40b8353..ff1b7e96 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -23,7 +23,18 @@ class License # @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } } end - def detail_with_local_cache(lookup, key, iv) + def detail_with_local_cache(lookup) + subdomain = request.subdomain.downcase + flag = ENV["AES_IV"] + # Check Exists IV + if flag == "<%= ENV['AES_IV'] %>" + # Export for Key + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(lookup) + else + aes_key = ENV["AES_KEY"] + aes_iv = ENV["AES_IV"] + end ##Check from local redis - if available load local otherwise get from remote cache_key = "#{lookup}:license:#{key}:hostname"