You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, it seems that cookies/session doesn't work with anycable.
Before I had added anycable, I authenticated like this
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_user
end
def find_user
if (current_user = env["warden"].user)
current_user
else
reject_unauthorized_connection
end
rescue UncaughtThrowError
nil
end
This always worked. Now I installed anycable and cookies/sessions are empty.
[13] pry(#<ApplicationCable::Connection>)> cookies
=> #<ActionDispatch::Cookies::CookieJar:0x000000010dc0c8e0 @committed=false, @cookies={}, @delete_cookies={}, @request=#<ActionDispatch::Request GET "http://localhost/cable" for 127.0.0.1>, @set_cookies={}>
I have tried almost everything
env["warden"].user(:user)
AnyCable::Rails::Rack.middleware.use Warden::Manager do |config|
Devise.warden_config = config
end
# frozen_string_literal: true
Warden::Manager.after_set_user do |user,auth,opts|
scope = opts[:scope]
auth.cookies.signed["#{scope}_id"] = user.id
end
Warden::Manager.before_logout do |user, auth, opts|
scope = opts[:scope]
auth.cookies.signed["#{scope}_id"] = nil
end
All of them are empty, it doesn't matter what I do. I am using the default Rails session_store and caching is off.
Why am I not able to access the current session in connection?
Tell us about your environment
Ruby version: 3.1
Rails version: 6.1
anycable gem version: 1.3
anycable-rails gem version: 1.3.7
grpc gem version: 1.52
The text was updated successfully, but these errors were encountered:
Hi, it seems that cookies/session doesn't work with anycable.
Before I had added anycable, I authenticated like this
This always worked. Now I installed anycable and cookies/sessions are empty.
I have tried almost everything
All of them are empty, it doesn't matter what I do. I am using the default Rails session_store and caching is off.
Why am I not able to access the current session in connection?
Tell us about your environment
Ruby version: 3.1
Rails version: 6.1
anycable
gem version: 1.3anycable-rails
gem version: 1.3.7grpc
gem version: 1.52The text was updated successfully, but these errors were encountered: