闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
429 B

  1. # frozen_string_literal: true
  2. module ApplicationCable
  3. class Connection < ActionCable::Connection::Base
  4. identified_by :current_user
  5. def connect
  6. self.current_user = find_verified_user
  7. end
  8. protected
  9. def find_verified_user
  10. catch :warden do
  11. verified_user = env['warden'].user
  12. return verified_user if verified_user
  13. end
  14. reject_unauthorized_connection
  15. end
  16. end
  17. end