Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01
This commit is contained in:
@@ -1,58 +1,65 @@
|
||||
class ActionController::Base
|
||||
before_action :lookup_domain, :set_locale
|
||||
before_action :lookup_domain if Rails.env.production?
|
||||
before_action :set_locale
|
||||
|
||||
helper_method :current_license,
|
||||
|
||||
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
|
||||
|
||||
private
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
logger.info "Location - " + @license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# authenticate_session_token
|
||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
if ENV["SERVER_MODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
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!'}]
|
||||
not_found
|
||||
end
|
||||
else
|
||||
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
else
|
||||
redirect_to activate_path
|
||||
if !check_license
|
||||
if ENV["SERVER_MODE"] == "application" || check_subdomain
|
||||
redirect_to activate_path
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def check_subdomain
|
||||
current_license.check_license_subdomain
|
||||
end
|
||||
|
||||
def check_license
|
||||
License.check_license_file
|
||||
if License.check_license_file(request.host)
|
||||
if current_license.expired?
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def check_installation
|
||||
@@ -64,7 +71,6 @@ class ActionController::Base
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
@@ -89,42 +95,58 @@ class ActionController::Base
|
||||
end
|
||||
|
||||
class ActionController::API
|
||||
before_action :lookup_domain
|
||||
before_action :lookup_domain if Rails.env.production?
|
||||
|
||||
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
|
||||
|
||||
private
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
logger.info "Location - " + @license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# authenticate_session_token
|
||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
if ENV["SERVER_CODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
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!'}]
|
||||
not_found
|
||||
end
|
||||
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
|
||||
not_found unless check_license
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def check_license
|
||||
if License.check_license_file(request.host)
|
||||
if current_license.expired?
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
|
||||
17
config/license.yml
Normal file
17
config/license.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
localhost:
|
||||
iv_key: 03TLQUDDVSOPa/lEEHqhVw==
|
||||
shop_name: scdemo3
|
||||
email: hanwintun@code2lab.com
|
||||
telephone: ''
|
||||
fax: ''
|
||||
address: ''
|
||||
dbhost: gG0jQLrVX6l0dZaA5wVP9bNTrfgzotwAcjcFKQmM9WUQ5121pkwg+9mYh5XDrIwL4//1UNjRR6CNZPorBMGtAw==
|
||||
dbschema: M9ddWoBb89JN51Ld1r7vTw==
|
||||
dbusername: 8Lc2lKIyJld/xfG6+ZxcOw==
|
||||
dbpassword: "+EhtSe5kJuVKp+wFMRlmoA=="
|
||||
api_token: UQFLAbMvJxUCnDVCOhIdqYZEGRqVQMvI
|
||||
app_token: DvRXGlomaBFpGVLYsidekVVZyqosntouTA
|
||||
plan_sku: 2NY6p1HAlR7UqE8AsBEytg==
|
||||
renewable_date: vlKVqrJyCB6LxXTkv63COg==
|
||||
plan_name: 6NSPpVHcwHBoFZPcVNjkvD6F5quXIWVaWieCRzpspbE=
|
||||
@@ -29,6 +29,9 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
delete 'logout' => 'home#destroy'
|
||||
get 'dashboard' => 'home#dashboard'
|
||||
|
||||
get 'expire' => 'renew_license#expire'
|
||||
get 'renew' => 'renew_license#renew'
|
||||
|
||||
namespace :induties do
|
||||
# resources :assign_in_duties
|
||||
get ':booking_id/assign' => 'assign_in_duties#index', as: :assign_in_duties
|
||||
@@ -244,23 +247,25 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'payment/dinga' => 'dinga#create'
|
||||
post 'payment/gift_voucher' => 'gift_voucher#create'
|
||||
post 'payment/credit_payment' => 'credit_payments#create_credit_payment'
|
||||
post 'payment/:method' => 'others_payments#create', :as => 'payment'
|
||||
|
||||
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
|
||||
|
||||
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/MPU' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/JCB' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Alipay' => "alipay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/DINGA' => "dinga#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/mpu' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/visa' => "visa#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/master' => "master#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/jcb' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/paymal' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/unionpay' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/voucher' => "voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/junctionpay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/alipay' => "alipay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/dinga' => "dinga#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
#---------Void --------------#
|
||||
post 'sale/:sale_id/:type/void' => 'void#overall_void'
|
||||
@@ -351,20 +356,22 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# post 'credit_payment/junctionpay' => 'junction_pay#create'
|
||||
# post 'credit_payment/dinga' => 'dinga#create'
|
||||
# post 'credit_payment/gift_voucher' => 'gift_voucher#create'
|
||||
post 'credit_payment/:method' => 'others_payments#create', :as => 'credit_payment'
|
||||
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/MPU' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/JCB' => "jcb#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Voucher' => "voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/mpu' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/visa' => "visa#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/master' => "master#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/jcb' => "jcb#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/paymal' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/unionpay' => "unionpay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/redeem' => "redeem_payments#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/voucher' => "voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/junctionpay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/alipay' => "alipay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/dinga' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
#------------- Start Reservation -------------------#
|
||||
resources :reservation
|
||||
|
||||
@@ -1049,6 +1049,13 @@
|
||||
"key": "MdrjwSyyNPqIU+HO3rwsHHSlG6xCKC5y3pQ1ywGbX2k=\n",
|
||||
"iv": "8+fEFUROBPpGp23jrRnb3Q==\n"
|
||||
}
|
||||
},
|
||||
{
|
||||
"lookup": "localhost",
|
||||
"value": {
|
||||
"key": "wyo9gq9KYY0FS1r1+cMmmAGEVGxQ2aTpVjfVYCoC9z4=\n",
|
||||
"iv": "T2UNnKc4EFLiDiALvjybdg==\n"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user