e3d86bb21e
Primarily this is in tests (which were caught by temporarily introducing acts_as_tenant and enabling safety checks), but notably action cable connections were not working properly, and that's now fixed.
23 lines
635 B
Ruby
23 lines
635 B
Ruby
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 = find_session_by_cookie
|
|
account = Account.find_by(external_account_id: request.env["fizzy.external_account_id"])
|
|
Current.account = account
|
|
self.current_user = session.identity.users.find_by!(account: account) if account
|
|
end
|
|
end
|
|
|
|
def find_session_by_cookie
|
|
Session.find_signed(cookies.signed[:session_token])
|
|
end
|
|
end
|
|
end
|