need to fix license

This commit is contained in:
Yan
2017-12-19 11:49:03 +06:30
parent 66200ef11a
commit 368405451f
5 changed files with 40 additions and 11 deletions

View File

@@ -69,11 +69,32 @@ class License
# For Local System
def detail_with_local_file()
has_license = true # verify_license()
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_key(lookup)
renewal_date_str = read_license("renewable_date")
if has_license
puts "VERIFIED"
# ##Check from local redis - if available load local otherwise get from remote
# renewable_date = "renewable_date:#{renewal_date_str}"
# ##Get redis connection from connection pool
# redis = Redis.new
# cache_renewable_date = redis.get(renewable_date)
# if cache_renewable_date.nil?
# redis = Redis.new
# redis.set(renewable_date, Marshal.dump(@license))
# else
# get_renewable_date = Marshal.load(cache_renewable_date)
if check_expiring(renewal_date_str)
return true
else
has_license = verify_license()
if has_license
puts "VERIFIED"
return true
end
end
# end
end
# License Activation
@@ -115,6 +136,12 @@ class License
return false
end
# Check Expired before 30 days
def check_expiring(renewal_date_str)
renewal_date = DateTime.parse(renewal_date_str)
renewal_date > Date.today.advance(:days => 30)
end
# Check License expired date from PROVISION SERVER
def check_expired(renewal_date_str)
renewal_date = DateTime.parse(renewal_date_str)
@@ -136,7 +163,7 @@ class License
if File.exist?("config/license.yml")
File.open("config/license.yml").each do |line|
if line.include? (key)
decrypted_line_array = line.split(": ")
decrypted_line_array = line.split(": ")
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE'])
end
end
@@ -185,6 +212,9 @@ class License
f.puts("dbpassword: #{response_data['dbpassword']}")
f.puts("api_token: #{response_data['api_token']}")
f.puts("app_token: #{response_data['app_token']}")
f.puts("plan_sku: #{response_data['plan_sku']}")
f.puts("renewable_date: #{response_data['renewable_date']}")
f.puts("plan_name: #{response_data['plan_name']}")
end
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}