我正在开发一个新的Rails 5(RC1)应用程序。我使用AuthLogic进行用户身份验证,并且它一直很好,直到我有了ActionCable。使AuthLogic与ActionCable一起工作
#app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = UserSession.find
end
end
end
我得到的错误:你必须用一个控制器对象激活Authlogic ::会议:: Base.controller创建对象
我尝试过:
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
但是,这并不因为Connection类不是控制器。
我看着AuthLogic代码,但我无法弄清楚如何绕过它对控制器对象的依赖。我只需要加载用户的会话。有什么想法吗?
很不错的解决方案!很好的答案。 请只编辑这一行:'self.current_user = find_verified_user' For:'self.current_user = find_verified_user_or_guest' – ZombieBsAs