add activation in license
This commit is contained in:
@@ -10,11 +10,14 @@ class InstallController < BaseController
|
||||
db_user = params[:db_user]
|
||||
db_password = params[:db_password]
|
||||
|
||||
|
||||
# Export for Key
|
||||
aes = MyAesCrypt.new
|
||||
aes_key, aes_iv = aes.export_key(lookup)
|
||||
|
||||
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||
@license.license_activate(aes_key, aes_iv, license_key)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
@license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
||||
|
||||
@@ -23,13 +23,13 @@ class License
|
||||
# @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
|
||||
end
|
||||
|
||||
def shop_code
|
||||
if ( self.subdomain.length > 3)
|
||||
return self.subdomain[0,3].upcase
|
||||
else
|
||||
return self.subdomain.upcase
|
||||
end
|
||||
end
|
||||
# def shop_code
|
||||
# if ( self.subdomain.length > 3)
|
||||
# return self.subdomain[0,3].upcase
|
||||
# else
|
||||
# return self.subdomain.upcase
|
||||
# end
|
||||
# end
|
||||
|
||||
def detail_with_local_cache(lookup, key, iv)
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
@@ -137,8 +137,18 @@ class License
|
||||
# end
|
||||
|
||||
# License Activation
|
||||
def license_activate
|
||||
def license_activate (key, iv, license_key)
|
||||
@params = { query: { lookup_type: self.server_mode, encrypted_key: key, iv_key: iv, license_key: license_key } }
|
||||
response = self.class.get("/activate", @params)
|
||||
@activate = response.parsed_response
|
||||
|
||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
||||
|
||||
if (@activate["status"])
|
||||
return create_license_file(@activate)
|
||||
else
|
||||
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
|
||||
end
|
||||
end
|
||||
|
||||
def verify_license
|
||||
@@ -216,6 +226,30 @@ class License
|
||||
|
||||
private
|
||||
|
||||
# License File Creation
|
||||
def create_license_file(response_data)
|
||||
if check_license_file
|
||||
delete_license_file
|
||||
end
|
||||
|
||||
begin
|
||||
# Licese File Creation
|
||||
f = File.open("config/license.yml", "w")
|
||||
f.write("name: #{response_data['name']}\n")
|
||||
f.write("shopname: #{response_data['shopname']}\n")
|
||||
f.write("dbhost: #{response_data['dbhost']}\n")
|
||||
f.write("dbschema: #{response_data['dbschema']}\n")
|
||||
f.write("dbusername: #{response_data['dbusername']}\n")
|
||||
f.write("dbpassword: #{response_data['dbpassword']}\n")
|
||||
f.write("api_token: #{response_data['api_token']}\n")
|
||||
f.write("app_token: #{response_data['app_token']}\n")
|
||||
f.close
|
||||
rescue IOError
|
||||
response = { "status": false, "message": "Can't create license file. Please contact code2lab call center!"}
|
||||
end
|
||||
response = { "status": true, "message": "License created"}
|
||||
end
|
||||
|
||||
# Delete License File
|
||||
def delete_license_file
|
||||
File.delete("config/license.yml") if File.exist?("config/license.yml")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
development:
|
||||
server_mode: cloud
|
||||
license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk
|
||||
|
||||
|
||||
@@ -9,6 +8,5 @@ test:
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
production:
|
||||
server_mode: cloud
|
||||
license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk
|
||||
|
||||
|
||||
Reference in New Issue
Block a user