update license activate
This commit is contained in:
@@ -16,9 +16,9 @@ App.checkin = App.cable.subscriptions.create('OutOfStockChannel', {
|
||||
|
||||
if (menus) {
|
||||
menus = jQuery.parseJSON(menus);
|
||||
menus.forEach(m =>
|
||||
m.categories.forEach(c =>
|
||||
c.items.forEach(i =>
|
||||
menus.forEach(m => {
|
||||
m.categories.forEach(c => {
|
||||
c.items.forEach(i => {
|
||||
i.instances.forEach(instance => {
|
||||
if (instance.code == item_code) {
|
||||
if (data.status == true) {
|
||||
@@ -33,9 +33,10 @@ App.checkin = App.cable.subscriptions.create('OutOfStockChannel', {
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
localStorage.setItem('menus', JSON.stringify(menus));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class InstallController < BaseController
|
||||
# aes_iv = ENV["AES_IV"]
|
||||
# end
|
||||
|
||||
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||
@license = License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
if response[:status]
|
||||
redirect_to root_url, notice: response["message"]
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
require 'yaml'
|
||||
|
||||
class License
|
||||
include HTTParty
|
||||
|
||||
base_uri "connect.smartsales.asia/api"
|
||||
base_uri "https://l.doemal.app//api"
|
||||
|
||||
attr_accessor :name, :address_1, :address_2, :township, :city, :country, :email, :phone, :fax, :logo, :subdomain,
|
||||
:plan_activation_date, :plan_next_renewal_date, :plan_max_products,:plan_max_customers, :plan_active_connections,
|
||||
:dbhost, :dbschema, :dbusername, :dbpassword, :exchange_unqiue_id, :localqueue_host,:server_mode,:localhost_address,
|
||||
:localqueue_user, :localqueue_password, :remotequeue_host, :remotequeue_user, :remotequeue_password, :api_token, :app_token
|
||||
:localqueue_user, :localqueue_password, :remotequeue_host, :remotequeue_user, :remotequeue_password, :api_token, :app_token, :lookup
|
||||
|
||||
@license = nil
|
||||
@secret = nil
|
||||
@@ -14,7 +16,10 @@ class License
|
||||
def initialize(server = "", lookup = "")
|
||||
#this code is hard-code to reflect server mode - Very important.
|
||||
self.server_mode = ENV["SERVER_MODE"]
|
||||
|
||||
unless ENV["SERVER_MODE"] == "cloud"
|
||||
self.server_mode = "application"
|
||||
end
|
||||
self.lookup = lookup
|
||||
if (server != "")
|
||||
self.class.base_uri server
|
||||
end
|
||||
@@ -189,8 +194,11 @@ class License
|
||||
end
|
||||
|
||||
# Check License File exists
|
||||
def self.check_license_file
|
||||
return File.exist?("config/license.yml")
|
||||
def self.check_license_file(lookup)
|
||||
return unless File.exist?("config/license.yml")
|
||||
if license = YAML.load_file("config/license.yml")
|
||||
license[lookup].present?
|
||||
end
|
||||
end
|
||||
|
||||
# read line by key for license file
|
||||
@@ -199,11 +207,8 @@ class License
|
||||
key, iv = get_redis_key()
|
||||
|
||||
if File.exist?("config/license.yml")
|
||||
File.open("config/license.yml").each do |line|
|
||||
if line.include? (key_name)
|
||||
decrypted_line_array = line.split(": ")
|
||||
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||
end
|
||||
if license = YAML.load(File.read("config/license.yml"))
|
||||
decrypted_line = AESCrypt.decrypt_data(decode_str(license[lookup][key_name]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||
end
|
||||
end
|
||||
return decrypted_line
|
||||
@@ -213,11 +218,8 @@ class License
|
||||
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
|
||||
if license = YAML.load_file("config/license.yml")
|
||||
decrypted_line = license[lookup][key]
|
||||
end
|
||||
end
|
||||
return decrypted_line
|
||||
@@ -231,18 +233,18 @@ class License
|
||||
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||
end
|
||||
|
||||
content_str = read_license_no_decrypt(content)
|
||||
if File.exist?("config/license.yml")
|
||||
file_str = File.read("config/license.yml")
|
||||
new_file_str = file_str.gsub(content_str, encode_str(crypted_str))
|
||||
if license = YAML.load_file("config/license.yml")
|
||||
license[lookup][content] = encode_str(crypted_str)
|
||||
|
||||
# To write changes to the file, use:
|
||||
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
|
||||
# To write changes to the file, use:
|
||||
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
|
||||
|
||||
# File.open("config/license.yml").each do |line|
|
||||
# new_file_str = line.gsub(content, crypted_str)
|
||||
# f.put
|
||||
# end
|
||||
# File.open("config/license.yml").each do |line|
|
||||
# new_file_str = line.gsub(content, crypted_str)
|
||||
# f.put
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -314,23 +316,41 @@ class License
|
||||
|
||||
begin
|
||||
# Licese File Creation
|
||||
File.open("config/license.yml", "w") do |f|
|
||||
f.puts("iv_key: #{response_data['iv_key']}")
|
||||
f.puts("shop_name: #{response_data['shop_name']}")
|
||||
f.puts("email: #{response_data['email']}")
|
||||
f.puts("telephone: #{response_data['telephone']}")
|
||||
f.puts("fax: #{response_data['fax']}")
|
||||
f.puts("address: #{response_data['address']}")
|
||||
f.puts("dbhost: #{response_data['dbhost']}")
|
||||
f.puts("dbschema: #{response_data['dbschema']}")
|
||||
f.puts("dbusername: #{response_data['dbusername']}")
|
||||
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
|
||||
# File.open("config/license.yml", "w") do |f|
|
||||
# f.puts("iv_key: #{response_data['iv_key']}")
|
||||
# f.puts("shop_name: #{response_data['shop_name']}")
|
||||
# f.puts("email: #{response_data['email']}")
|
||||
# f.puts("telephone: #{response_data['telephone']}")
|
||||
# f.puts("fax: #{response_data['fax']}")
|
||||
# f.puts("address: #{response_data['address']}")
|
||||
# f.puts("dbhost: #{response_data['dbhost']}")
|
||||
# f.puts("dbschema: #{response_data['dbschema']}")
|
||||
# f.puts("dbusername: #{response_data['dbusername']}")
|
||||
# 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
|
||||
license = {lookup => {"iv_key" => response_data['iv_key'],
|
||||
"shop_name" => response_data['shop_name'],
|
||||
"email" => response_data['email'],
|
||||
"telephone" => response_data['telephone'],
|
||||
"fax" => response_data['fax'],
|
||||
"address" => response_data['address'],
|
||||
"dbhost" => response_data['dbhost'],
|
||||
"dbschema" => response_data['dbschema'],
|
||||
"dbusername" => response_data['dbusername'],
|
||||
"dbpassword" => response_data['dbpassword'],
|
||||
"api_token" => response_data['api_token'],
|
||||
"app_token" => response_data['app_token'],
|
||||
"plan_sku" => response_data['plan_sku'],
|
||||
"renewable_date" => response_data['renewable_date'],
|
||||
"plan_name" => response_data['plan_name']}
|
||||
}
|
||||
|
||||
File.open("config/license.yml", "w"){ |file| file.write(license.to_yaml) }
|
||||
rescue IOError
|
||||
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||
end
|
||||
|
||||
@@ -20,7 +20,8 @@ Rails.application.configure do
|
||||
#config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
# config.assets.js_compressor = :uglifier
|
||||
config.assets.js_compressor = Uglifier.new(harmony: true)
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
if File.exist?("config/license.yml")
|
||||
config = YAML.load_file(Rails.root.join("config/license.yml"))
|
||||
config.fetch(Rails.env, {}).each do |key, value|
|
||||
ENV[key.upcase] = value.to_s
|
||||
if config
|
||||
config.fetch(Rails.env, {}).each do |key, value|
|
||||
ENV[key.upcase] = value.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ test:
|
||||
# instead read values from the environment.
|
||||
production:
|
||||
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
||||
sx_provision_url: connect.smartsales.asia/api #52.221.188.144:9292/api #192.168.1.147:3002/api
|
||||
sx_provision_url: l.doemal.app/api #52.221.188.144:9292/api #192.168.1.147:3002/api
|
||||
server_mode: application
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user