ADD action cable for migrate project

This commit is contained in:
Jasder
2020-07-02 15:49:22 +08:00
parent ba79b8f4e6
commit c1a5c390f7
14 changed files with 100 additions and 11 deletions

View File

@@ -1,4 +1,20 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
logger.add_tags 'ActionCable', current_user.id
end
private
def find_verified_user
puts "############### cookies.signed[:signed_user_id]: #{cookies.signed[:user_id]}"
if current_user = User.find_by(id: cookies.signed[:user_id])
current_user
else
reject_unauthorized_connection
end
end
end
end