license activate

This commit is contained in:
Yan
2017-11-29 17:59:46 +06:30
parent a1deab2b5e
commit 29fa95d229
4 changed files with 13 additions and 9 deletions

View File

@@ -1,10 +1,14 @@
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]
@@ -13,12 +17,13 @@ class InstallController < BaseController
db_schema = params[:db_schema]
db_user = params[:db_user]
db_password = params[:db_password]
phrase = key_base == "<%= ENV['secret_key_base'] %>"? license_key : "<%= ENV['secret_key_base'] %>"
# Check Exists IV
if flag == "<%= ENV['AES_IV'] %>"
# Export for Key
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_key(lookup)
aes_key, aes_iv = aes.export_key(phrase)
else
aes_key = ENV["AES_KEY"]
aes_iv = ENV["AES_IV"]
@@ -26,7 +31,7 @@ class InstallController < BaseController
@license = License.new(ENV["SX_PROVISION_URL"])
response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password)
if response["status"]
if response[:status]
redirect_to root_url, notice: response["message"]
else
redirect_to activate_path, notice: response["message"]

View File

@@ -74,7 +74,7 @@ class License
def detail_with_local_file()
has_license = true # verify_license()
has_license = true #verify_license()
if has_license
# puts "VERIFIED"
@@ -156,14 +156,13 @@ class License
# License File Creation
def create_license_file(response_data)
if check_license_file
if File.exist?("config/license.yml")
delete_license_file
end
begin
# Licese File Creation
f = File.open("config/license.yml", "w")
f.write("name: #{response_data['name']}\n")
f = File.open("config/license.yml", "w")
f.write("iv_key: #{response_data['iv_key']}\n")
f.write("shop_name: #{response_data['shop_name']}\n")
f.write("email: #{response_data['email']}\n")

View File

@@ -1,4 +1,4 @@
<form action="/install" method="POST" class="row">
<form action="/activate" method="POST" class="row">
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">Business Name</label>

View File

@@ -13,7 +13,7 @@
development:
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api
server_mode: cloud
server_mode: application
cipher_type: AES-256-CBC
aes_key: <%= ENV['AES_KEY'] %>
aes_iv: <%= ENV['AES_IV'] %>