update cable
This commit is contained in:
@@ -9,6 +9,12 @@
|
|||||||
(function() {
|
(function() {
|
||||||
this.App || (this.App = {});
|
this.App || (this.App = {});
|
||||||
|
|
||||||
|
// var hostname = location.hostname;
|
||||||
|
// var port = location.port;
|
||||||
|
// var host = hostname + ":" + port + "/cable"
|
||||||
|
// console.log(host);
|
||||||
|
// App.cable = ActionCable.createConsumer();
|
||||||
|
// console.log(App.cable);
|
||||||
App.cable = ActionCable.createConsumer();
|
App.cable = ActionCable.createConsumer();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
App.order = App.cable.subscriptions.create('OrderChannel', {
|
App.order = App.cable.subscriptions.create('OrderChannel', {
|
||||||
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
|
||||||
|
|
||||||
connected: function() {},
|
connected: function() {},
|
||||||
|
|
||||||
disconnected: function() {},
|
disconnected: function() {},
|
||||||
|
|||||||
@@ -1,7 +1,27 @@
|
|||||||
module ApplicationCable
|
module ApplicationCable
|
||||||
class Connection < ActionCable::Connection::Base
|
class Connection < ActionCable::Connection::Base
|
||||||
|
identified_by :current_subdomain
|
||||||
def connect
|
def connect
|
||||||
|
if ENV["server_mode"] == "cloud"
|
||||||
|
self.current_subdomain = verified_subdomain
|
||||||
|
end
|
||||||
logger.add_tags "SX-ActionCable"
|
logger.add_tags "SX-ActionCable"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def verified_subdomain
|
||||||
|
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||||
|
file_path = "config/shops.json"
|
||||||
|
shop_data = File.read(file_path)
|
||||||
|
|
||||||
|
shop_json = JSON.parse(shop_data)
|
||||||
|
shop_json["data"].each do |j|
|
||||||
|
if j["lookup"] == from
|
||||||
|
verified_subdomain = from
|
||||||
|
else
|
||||||
|
reject_unauthorized_connection
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ class ActionController::Base
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user