diff options
Diffstat (limited to 'app/channels/application_cable/connection.rb')
-rw-r--r-- | app/channels/application_cable/connection.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 00000000000..87c833f3593 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module ApplicationCable + class Connection < ActionCable::Connection::Base + identified_by :current_user + + def connect + self.current_user = find_user_from_session_store + end + + private + + def find_user_from_session_store + session = ActiveSession.sessions_from_ids([session_id]).first + Warden::SessionSerializer.new('rack.session' => session).fetch(:user) + end + + def session_id + Rack::Session::SessionId.new(cookies[Gitlab::Application.config.session_options[:key]]) + end + end +end |