aboutsummaryrefslogtreecommitdiffstats
path: root/app/channels
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-11-11 16:19:44 +0000
committerMatthew Lemon <y@yulqen.org>2024-11-11 16:19:44 +0000
commit97201e0bca203b6b303789374ffd7e4228e062a7 (patch)
tree1d70b0c499c514ceccd906b6b6e85dcbacbd3f45 /app/channels
initial after migration
Diffstat (limited to 'app/channels')
-rw-r--r--app/channels/application_cable/connection.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..4264c74
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,16 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ 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
+ end
+end