update multi_tenancy/license

This commit is contained in:
Thein Lin Kyaw
2020-01-29 14:20:50 +06:30
parent 0ea212bf65
commit 11ffaa738f
7 changed files with 37 additions and 38 deletions

View File

@@ -219,26 +219,22 @@ class License
# read line by key for license file
def read_license(key_name)
decrypted_line = ""
key, iv = get_redis_key()
if File.exist?("config/license.yml")
if license = YAML.load(File.read("config/license.yml"))
decrypted_line = AESCrypt.decrypt_data(decode_str(license[lookup][key_name]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
AESCrypt.decrypt_data(decode_str(license[lookup][key_name]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
end
return decrypted_line
end
# read line by key for license file without decrypt
def read_license_no_decrypt(key)
decrypted_line = ""
if File.exist?("config/license.yml")
if license = YAML.load_file("config/license.yml")
decrypted_line = license[lookup][key]
end
end
return decrypted_line
end
# Update license file for line
@@ -255,11 +251,6 @@ class License
# To write changes to the file, use:
File.open("config/license.yml", "w") {|file| file.write(license.to_yaml) }
# File.open("config/license.yml").each do |line|
# new_file_str = line.gsub(content, crypted_str)
# f.put
# end
end
end
end
@@ -306,6 +297,7 @@ class License
redis = Redis.new
cache_shop = redis.get(cache_key)
puts Marshal.load(cache_shop)
if !cache_shop.nil?
@shop = Marshal.load(cache_shop)
key = @shop["key"]