Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. module ApplicationCable
  2. class Connection < ActionCable::Connection::Base
  3. identified_by :current_user
  4.  
  5. def connect
  6. self.current_user = find_verified_user
  7. logger.add_tags 'ActionCable', current_user.username
  8. end
  9.  
  10. protected
  11.  
  12. def find_verified_user
  13. if verified_user = env['warden'].session?(:user)
  14. verified_user
  15. else
  16. reject_unauthorized_connection
  17. end
  18. end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement