license renew page

This commit is contained in:
Zin Moe
2020-06-04 10:10:04 +06:30
parent da75403437
commit bd18958b96
16 changed files with 181 additions and 55 deletions

View File

@@ -78,7 +78,7 @@ class License
def detail_with_local_file
if expired?
return 0
elsif expire_in(30)?
elsif expire_in?(10)
return 2
else
return 1
@@ -151,15 +151,23 @@ class License
def verify_license
api_token = read_license_no_decrypt("api_token")
@params = { query: {lookup_type: "application", api_token: api_token} }
old_renewable_date = read_license("renewable_date")
begin
response = self.class.get("/verify", @params)
@varified = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@varified["status"])
if (!check_expired(@varified["renewable_date"]))
return true
if old_renewable_date.to_date == @varified['renewable_date'].to_date
message = "*** License couldn't be verified. ***"
status = 2
elsif old_renewable_date.to_date < @varified['renewable_date'].to_date
update_license("renewable_date", @varified['renewable_date'])
status = 1
message = "*** License could be verified. ***"
end
return status, message
else
delete_license_file
end
@@ -330,7 +338,6 @@ 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"]