Skip to content

Commit

Permalink
turbo-stream-verify-authorised-connection (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpaul authored Apr 23, 2024
2 parents 59401f0 + 1a48a5e commit 5fe51ad
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user

def connect
self.current_user = find_verified_user
logger.add_tags "ActionCable", "User #{current_user.id}"
end

protected

def find_verified_user
if verified_user = env["warden"].user
verified_user
else
reject_unauthorized_connection
end
end

def user_signed_in?
!!current_user
end
end
end

0 comments on commit 5fe51ad

Please sign in to comment.