1
我在我的應用程序上使用ActinCable,並且我遇到了授權問題。目前,actioncable試圖授權在網站上生活的每一個人,一如既往。僅將用戶連接到ActionCable
這將在我的日誌中返回一個恆定的流An unauthorized connection attempt was rejected
。現在這是因爲訪問那些人沒有登錄,也試圖獲得訪問權限。
我connection.rb
看起來是這樣的:
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
protected
def find_verified_user
if current_user = User.find_by(id: cookies.signed[:user_id])
current_user
else
reject_unauthorized_connection
end
end
end
end
現在我想知道如果我可以讓這個只有那些簽署人,努力成爲受connnection.rb
而是採用了現場每一位來訪者的授權。我對ActionCable非常不熟悉,不知道如何限制這一點 - ActionCable的文檔還處於早期階段。