74 lines
1.9 KiB
Ruby
Executable File
74 lines
1.9 KiB
Ruby
Executable File
class InstallController < BaseController
|
|
# skip_before_action :set_current_tenant_by_subdomain_or_name
|
|
skip_before_action :verify_authenticity_token
|
|
|
|
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"], 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
|
|
redirect_to activate_path, notice: response["message"]
|
|
end
|
|
end
|
|
|
|
def lookup_domain
|
|
if ENV["SERVER_MODE"] == "cloud"
|
|
not_found
|
|
elsif ENV["SERVER_MODE"] == "application"
|
|
if check_license #(request.host)
|
|
redirect_to root_url
|
|
end
|
|
elsif request.subdomains.last && request.subdomains.last != "www"
|
|
if check_license #(request.host)
|
|
redirect_to root_url
|
|
elsif !check_subdomain(request.host)
|
|
not_found
|
|
end
|
|
else
|
|
not_found
|
|
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
|