modify generate auth token method

This commit is contained in:
Zin Moe
2020-01-14 15:34:02 +06:30
parent 3f338f2073
commit 37ff82ae5d
2 changed files with 24 additions and 22 deletions

View File

@@ -100,5 +100,7 @@ class Employee < ApplicationRecord
def generate_auth_token def generate_auth_token
return if self.role != 'app' return if self.role != 'app'
self.auth_token = SecureRandom.hex(10) self.auth_token = SecureRandom.hex(10)
rescue ActiveRecord::RecordNotUnique
retry
end end
end end

View File

@@ -4,28 +4,28 @@ class ActionController::Base
private private
def lookup_domain def lookup_domain
# if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud"
# from = request.host from = request.host
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
# if (!@license.nil?) if (!@license.nil?)
# logger.info "Location - " + @license.dbschema logger.info "Location - " + @license.dbschema
# ActiveRecord::Base.establish_connection(website_connection(@license)) ActiveRecord::Base.establish_connection(website_connection(@license))
# # authenticate_session_token # authenticate_session_token
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
# else else
# # reconnect_default_db # reconnect_default_db
# logger.info 'License is nil' logger.info 'License is nil'
# # redirect_to root_url(:host => request.domain) + "store_error" # redirect_to root_url(:host => request.domain) + "store_error"
# render :json => [{ status: false, message: 'Invalid Access!'}] render :json => [{ status: false, message: 'Invalid Access!'}]
# end end
# else else
# # check for license file # check for license file
# if check_license if check_license
# current_license(ENV["SX_PROVISION_URL"]) current_license(ENV["SX_PROVISION_URL"])
# else else
# redirect_to activate_path redirect_to activate_path
# end end
# end end
end end