add license

This commit is contained in:
Yan
2017-11-09 14:41:35 +06:30
parent eba30f6566
commit 121338677c
4 changed files with 12 additions and 22 deletions

View File

@@ -13,14 +13,14 @@ class License
def initialize(server = "", lookup = "")
#this code is hard-code to reflect server mode - Very important.
self.server_mode = "cloud"
self.server_mode = ENV["server_mode"]
if (server != "")
self.class.base_uri server
end
@secret = SecureRandom.hex(10)
@params = { query: { device: "SXlite", token: SECRETS_CONFIG['provision_key'] } }
@params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
end
def shop_code
@@ -106,7 +106,7 @@ class License
def check_remote_license(license_key)
# @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} }
@options = { query: {device: "SXlite", key: license_key, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
@options = { query: {device: "SX", key: license_key, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
response = self.class.get("/license", @options)
@license = response.parsed_response
@@ -120,7 +120,7 @@ class License
end
def verify_by_api_token(api_token)
@options = { query: {device: "SXlite", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
@options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
response = self.class.get("/verify", @options)
@license = response.parsed_response