0

From action cable documentation I read this example for setting current_user:

module ApplicationCable
  class Connection < ActionCable::Connection::Base
    identified_by :current_user

  def connect
    self.current_user = find_verified_user
  end

  private
    def find_verified_user
      if verified_user = User.find_by(id: cookies.signed[:user_id])
        verified_user
      else
        reject_unauthorized_connection
      end
    end
  end
end

I don't have user_id cookie set because authentication is made for a cas server, and it store session in Active Record. How tell to Connection class the current user?

1 Answers1

0

You need to force the session to load. Check this link here (worked for me): How force that session is loaded?

vasilakisfil
  • 2,279
  • 4
  • 24
  • 31