78 lines
2.3 KiB
Ruby
Executable File
78 lines
2.3 KiB
Ruby
Executable File
class InstallController < BaseController
|
|
skip_before_action :verify_authenticity_token
|
|
# before_action :check_license
|
|
|
|
def index
|
|
end
|
|
|
|
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]
|
|
# admin_password = params[:admin_password]
|
|
db_host = params[:db_host]
|
|
db_schema = params[:db_schema]
|
|
db_user = params[:db_user]
|
|
db_password = params[:db_password]
|
|
phrase = license_key
|
|
|
|
# Check Exists IV
|
|
# if flag == "<%= ENV['AES_IV'] %>"
|
|
# # Export for Key
|
|
# aes = MyAesCrypt.new
|
|
# aes_key, aes_iv = aes.export_key(phrase)
|
|
# 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)
|
|
if response[:status]
|
|
redirect_to root_url, notice: response["message"]
|
|
else
|
|
redirect_to activate_path, notice: response["message"]
|
|
end
|
|
end
|
|
|
|
def check_license
|
|
if License.check_license_file
|
|
redirect_to root_url
|
|
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)
|
|
|
|
# ##creating md5 hash
|
|
# md5_hostname = Digest::MD5.new
|
|
# md5key = md5_hostname.update(request.host)
|
|
# if (@license.detail_with_local_cache(key, md5key.to_s) == true)
|
|
# #if (@license.detail == true)
|
|
|
|
# return @license
|
|
# else
|
|
# return nil
|
|
# end
|
|
# end
|
|
end
|