2024-07-11 18:42:31 +02:00
|
|
|
module ApplicationCable
|
|
|
|
class Connection < ActionCable::Connection::Base
|
2024-11-19 00:26:44 +01:00
|
|
|
identified_by :current_user
|
|
|
|
|
|
|
|
def connect
|
|
|
|
set_current_user || reject_unauthorized_connection
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def set_current_user
|
|
|
|
if session = Session.find_by(id: cookies.signed[:session_id])
|
|
|
|
self.current_user = session.user
|
|
|
|
end
|
|
|
|
end
|
2024-07-11 18:42:31 +02:00
|
|
|
end
|
|
|
|
end
|