How do I get current_user in ActionCable rails-5-api app?

后端 未结 5 1645
故里飘歌
故里飘歌 2020-12-15 20:57

Why am I not able to retrieve current_user inside my channel or how should I retrieve current_user?

What do I use?

  • Rails 5.0.
5条回答
  •  执笔经年
    2020-12-15 21:28

    if you are using devise gems in rails, Please replace this function:

    def find_verified_user # this checks whether a user is authenticated with devise
      if verified_user = env['warden'].user
        verified_user
      else
        reject_unauthorized_connection
      end
    end
    

    I hope this will help you.

提交回复
热议问题