diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index cf16adfe..9b4d88c2 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -2,13 +2,19 @@ class InstallController < BaseController def index end - def create + def activate restaurant = params[:restaurant_name] license_key = params[:license_key] admin_user = params[:admin_user] admin_password = params[:admin_password] + db_user = params[:db_user] + db_password = params[:db_password] + + end + + def lookup_domain if request.subdomain.present? && request.subdomain != "www" @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) diff --git a/app/models/license.rb b/app/models/license.rb index 31403038..eb81c142 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -80,6 +80,7 @@ class License if has_license puts "VERIFIED" end + end # if cache_license.nil? # ##change the d/e key @@ -119,26 +120,31 @@ class License # return false end - def detail - response = self.class.get("/subdomain", @options) - @license = response.parsed_response + # def detail + # response = self.class.get("/subdomain", @options) + # @license = response.parsed_response - Rails.logger.debug "License - " + response.parsed_response.to_s + # Rails.logger.debug "License - " + response.parsed_response.to_s - if (@license["status"] == true) - assign() + # if (@license["status"] == true) + # assign() - return true - end + # return true + # end + + # return false + # end + + # License Activation + def license_activate - return false end def verify_license api_token = read_license("api_token") - @options = { query: {lookup_type: "application", token: api_token} } - response = self.class.get("/verify", @options) + @params = { query: {lookup_type: "application", token: api_token} } + response = self.class.get("/verify", @params) @varified = response.parsed_response Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s @@ -152,37 +158,36 @@ class License return false end - def check_remote_license(license_key) - # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} } - @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} } - response = self.class.get("/license", @options) + # def check_remote_license(license_key) + # # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} } + # @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} } + # response = self.class.get("/license", @options) - @license = response.parsed_response + # @license = response.parsed_response - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@license["status"]) - assign() - end - return @license["status"] + # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + # if (@license["status"]) + # assign() + # end + # return @license["status"] + # end - end + # def verify_by_api_token(api_token) + # @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} } + # response = self.class.get("/verify_token", @options) - def verify_by_api_token(api_token) - @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} } - response = self.class.get("/verify", @options) + # @license = response.parsed_response - @license = response.parsed_response + # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + # if (@license["status"]) + # assign() + # end - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@license["status"]) - assign() - end - - return @license["status"] - end + # return @license["status"] + # end #Load License is remove from the cloud license because - this license is must be validated against subdmain instead of license.data from file. - + # Check License expired date from PROVISION SERVER def check_expired(renewal_date) if (renewal_date < Date.today) return true @@ -191,6 +196,7 @@ class License end end + # Check License File exists def self.check_license_file return File.exist?("config/license.yml") end @@ -209,6 +215,13 @@ class License end private + + # Delete License File + def delete_license_file + File.delete("config/license.yml") if File.exist?("config/license.yml") + end + + # Assign db info for Cloud def assign # self.name = @license["name"] # self.address_1 = @license["address_1"] @@ -228,7 +241,6 @@ class License ## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d") ## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d") - # self.plan_max_products = @license["plan_max_products"].to_i # self.plan_max_customers = @license["plan_max_customers"].to_i # self.plan_active_connections = @license["plan_active_connections"].to_i diff --git a/config/routes.rb b/config/routes.rb index 64f68262..a44cc1c4 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- SmartSales Installation ------------# get 'install' => 'install#index' - post 'install' => 'install#create' + post 'install' => 'install#activate' #--------- Login/Authentication ------------# get 'auth/:emp_id' => 'home#show', as: :emp_login