Merge branch 'foodcourt' of gitlab.com:code2lab/SXRestaurant into foodcourt
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ module MultiTenancy
|
||||
end
|
||||
|
||||
def find_tenant_by_subdomain_or_frist
|
||||
if request.subdomains.last && request.subdomains.last != 'www'
|
||||
if request.subdomains.last && request.subdomains.last != "www"
|
||||
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
|
||||
elsif ENV["SERVER_MODE"] == "application"
|
||||
set_current_tenant(Shop.first)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class InstallController < BaseController
|
||||
skip_before_action :lookup_domain
|
||||
skip_before_action :set_current_tenant_by_subdomain_or_first
|
||||
skip_before_action :verify_authenticity_token
|
||||
# before_action :check_license
|
||||
|
||||
def index
|
||||
end
|
||||
@@ -9,7 +8,7 @@ class InstallController < BaseController
|
||||
def activate
|
||||
flag = "<%= ENV['AES_IV'] %>"
|
||||
key_base = "<%= ENV['secret_key_base'] %>"
|
||||
|
||||
|
||||
restaurant = params[:restaurant_name]
|
||||
license_key = params[:license_key]
|
||||
# admin_user = params[:admin_user]
|
||||
@@ -18,20 +17,20 @@ class InstallController < BaseController
|
||||
db_schema = params[:db_schema]
|
||||
db_user = params[:db_user]
|
||||
db_password = params[:db_password]
|
||||
phrase = license_key
|
||||
|
||||
phrase = license_key
|
||||
|
||||
# Check Exists IV
|
||||
# if flag == "<%= ENV['AES_IV'] %>"
|
||||
# # Export for Key
|
||||
# aes = MyAesCrypt.new
|
||||
# # Export for Key
|
||||
# aes = MyAesCrypt.new
|
||||
# aes_key, aes_iv = aes.export_key(phrase)
|
||||
# else
|
||||
# else
|
||||
# aes_key = ENV["AES_KEY"]
|
||||
# aes_iv = ENV["AES_IV"]
|
||||
# end
|
||||
|
||||
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
@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"]
|
||||
else
|
||||
@@ -39,28 +38,17 @@ class InstallController < BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
redirect_to root_url
|
||||
def lookup_domain
|
||||
if (ENV["SERVER_MODE"] == "application") ||
|
||||
(request.subdomain.present? && request.subdomain != "www" && ENV["SERVER_MODE"] != "cloud")
|
||||
if check_license(request.host)
|
||||
redirect_to root_url
|
||||
end
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
||||
# if (!@license.nil?)
|
||||
# # logger.info "Location - " + @license.name
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def current_license(url, key)
|
||||
# @license = License.new(url, key)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -20,25 +20,25 @@ class ActionController::Base
|
||||
end
|
||||
elsif request.subdomain.present? && request.subdomain != "www" || ENV["SERVER_MODE"] == "application"
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
if check_license(request.host)
|
||||
current_license(ENV["SX_PROVISION_URL"], request.host)
|
||||
else
|
||||
redirect_to activate_path
|
||||
end
|
||||
else
|
||||
render_not_found
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def render_not_found
|
||||
def not_found
|
||||
respond_to do |format|
|
||||
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
|
||||
format.json { head :not_found }
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
def current_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
@@ -59,8 +59,8 @@ class ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def check_license
|
||||
License.check_license_file
|
||||
def check_license(lookup)
|
||||
License.check_license_file(lookup)
|
||||
end
|
||||
|
||||
def check_installation
|
||||
|
||||
@@ -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
@@ -1,9 +1,9 @@
|
||||
namespace :shop do
|
||||
desc "Create shop and seed data"
|
||||
task :create, [:name, :shop_code, :client_name, :client_code, :address, :phone_no] => :environment do |t, args|
|
||||
task :create, [:name, :shop_code, :subdomain, :client_name, :client_code, :address, :phone_no] => :environment do |t, args|
|
||||
|
||||
ActiveRecord::Base.connection.execute("INSERT INTO shops (logo, name, shop_code, subdomain, client_name, client_code, address, township, city, state, country, phone_no, reservation_no, license, activated_at, license_data, base_currency, cloud_url, cloud_token, owner_token, id_prefix, is_rounding_adj, quick_sale_summary, calc_tax_order, show_account_info, note, created_at, updated_at)
|
||||
VALUES (NULL, '#{args.name}', '#{args.shop_code}', '#{args.name}-#{args.shop_code}', '#{args.client_name}', '#{args.client_code}', '#{args.address}', '', '', '', '', '#{args.phone_no}', '111', '', CURRENT_TIMESTAMP(), 'test', '111', NULL, NULL, NULL, '111', 0, 0, 0, 1, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP())")
|
||||
VALUES (NULL, '#{args.name}', '#{args.shop_code}', '#{args.subdomain}', '#{args.client_name}', '#{args.client_code}', '#{args.address}', '', '', '', '', '#{args.phone_no}', '111', '', CURRENT_TIMESTAMP(), 'test', '111', NULL, NULL, NULL, '111', 0, 0, 0, 1, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP())")
|
||||
logger.info " Shop created for #{args.name}-#{args.shop_code}"
|
||||
|
||||
gateway_communication_type =Lookup.create([{lookup_type:'gateway_communication_type',name: 'API',value: 'api',shop_code: args.shop_code},
|
||||
|
||||
Reference in New Issue
Block a user