implement alternative match-making approach with Lua scripts in Redis
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
identified_by :current_user
|
||||
|
||||
def connect
|
||||
self.current_user = find_user
|
||||
reject_unauthorized_connection unless current_user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_user
|
||||
token = request.params[:token].presence ||
|
||||
request.headers["Authorization"]&.split(" ")&.last
|
||||
return unless token
|
||||
|
||||
decoded = JwtService.decode(token)
|
||||
User.find_by(id: decoded[:user_id]) if decoded
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user