added license

This commit is contained in:
Yan
2017-11-16 16:13:26 +06:30
parent b1f98df4e0
commit 178b3484be
10 changed files with 264 additions and 184 deletions

View File

@@ -1,12 +1,16 @@
class InstallController < BaseController
before_action :check_license
def index
end
def activate
restaurant = params[:restaurant_name]
license_key = params[:license_key]
admin_user = params[:admin_user]
admin_password = params[:admin_password]
# 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]
@@ -15,37 +19,48 @@ class InstallController < BaseController
aes_key, aes_iv = aes.export_key(lookup)
@license = License.new(ENV["SX_PROVISION_URL"])
@license.license_activate(aes_key, aes_iv, license_key)
response = @license.license_activate(aes_key, aes_iv, 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 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
def check_license
if License.check_license_file
redirect_to root_url
end
end
def current_license(url, key)
@license = License.new(url, key)
# 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
##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)
# def current_license(url, key)
# @license = License.new(url, key)
return @license
else
return nil
end
end
# ##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