Skip to content

Commit

Permalink
feat: use session in anycable
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Nov 11, 2019
1 parent c46fdf7 commit c24f4ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gem 'redis', '~> 4.0'
# gem 'bcrypt', '~> 3.1.7'

# Efficient ActionCable replacement to use web-sockets
gem 'anycable-rails', '~> 0.6'
gem 'anycable-rails', '~> 0.6', github: "anycable/anycable-rails", branch: "feature/rack-middleware"

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
Expand Down
18 changes: 12 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/anycable/anycable-rails.git
revision: 59ebcbf9033725637b08dee5cbd5e26891dfc354
branch: feature/rack-middleware
specs:
anycable-rails (0.6.4)
anycable (~> 0.6.0)
rails (>= 5)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -45,9 +54,6 @@ GEM
anycable (0.6.3)
anyway_config (~> 1.4.2)
grpc (~> 1.17)
anycable-rails (0.6.4)
anycable (~> 0.6.0)
rails (>= 5)
anyway_config (1.4.4)
arel (9.0.0)
bindex (0.8.1)
Expand All @@ -62,10 +68,10 @@ GEM
ffi (1.11.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
google-protobuf (3.9.2)
google-protobuf (3.10.1)
googleapis-common-protos-types (1.0.4)
google-protobuf (~> 3.0)
grpc (1.24.0)
grpc (1.25.0)
google-protobuf (~> 3.8)
googleapis-common-protos-types (~> 1.0)
i18n (1.6.0)
Expand Down Expand Up @@ -166,7 +172,7 @@ PLATFORMS
ruby

DEPENDENCIES
anycable-rails (~> 0.6)
anycable-rails (~> 0.6)!
bootsnap (>= 1.1.0)
byebug
jbuilder (~> 2.5)
Expand Down
6 changes: 0 additions & 6 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ def connect
self.current_user = session.fetch("username", nil)
reject_unauthorized_connection unless current_user
end

# By default we don't have access to the session object
# https://edgeguides.rubyonrails.org/action_cable_overview.html#notes
def session
cookies.encrypted[Rails.application.config.session_options[:key]] || {}
end
end
end

0 comments on commit c24f4ea

Please sign in to comment.