Files
fizzy/app/channels/application_cable/connection.rb
T
Stanko Krtalić 98755844a1 Remove the internal API
* Bind sessions to identities
* Remove references to the identity token
* Move email changes to identity
* Move account menu into a turbo-frame
* Create tenants from a tenanted route
2025-10-31 16:26:08 +01:00

23 lines
579 B
Ruby

module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
super
set_current_user || reject_unauthorized_connection
end
private
def set_current_user
if session = find_session_by_cookie
membership = session.identity.memberships.find_by!(tenant: current_tenant)
self.current_user = membership.user if membership.user.active?
end
end
def find_session_by_cookie
Session.find_signed(cookies.signed[:session_token])
end
end
end