license verify

This commit is contained in:
Yan
2017-12-01 17:35:56 +06:30
parent a50b49d2ac
commit 4548813bfd
3 changed files with 29 additions and 13 deletions

View File

@@ -74,10 +74,10 @@ class License
def detail_with_local_file()
has_license = true #verify_license()
has_license = verify_license()
if has_license
# puts "VERIFIED"
puts "VERIFIED"
end
end
@@ -103,9 +103,10 @@ class License
return response
end
def verify_license
api_token = read_license("api_token")
@params = { query: {lookup_type: "application", token: api_token} }
def verify_license
api_token = read_license_no_decrypt("api_token")
puts api_token
@params = { query: {lookup_type: "application", api_token: api_token} }
response = self.class.get("/verify", @params)
@varified = response.parsed_response
@@ -121,7 +122,8 @@ class License
end
# Check License expired date from PROVISION SERVER
def check_expired(renewal_date)
def check_expired(renewal_date_str)
renewal_date = DateTime.parse(renewal_date_str)
if (renewal_date < Date.today)
return true
else
@@ -148,6 +150,20 @@ class License
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")
File.open("config/license.yml").each do |line|
if line.include? (key)
decrypted_line_array = line.split(": ")
decrypted_line = decrypted_line_array[1]
end
end
end
return decrypted_line
end
private
def decode_str(str)