module ApplicationCable # The WebSocket knows the signed-in user from the same session cookie as # the rest of the app. Anonymous connections are allowed: a share link # token (a subscription parameter) can grant access on its own. class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = Session.find_by(id: cookies.signed[:session_id])&.user if cookies.signed[:session_id] end end end