Devise - Make a request without resetting the countdown until a user is logged out due to inactivity

后端 未结 4 1130
孤城傲影
孤城傲影 2020-12-15 19:18

I\'m working on a RoR app with Devise. I want to let clients send a request to the server to see how much time is left until the user on the client is automatically logged o

4条回答
  •  一整个雨季
    2020-12-15 19:56

    The two leading answers of prepending a request.env["devise.skip_trackable"] = true action did not work for me initially.

    It seems that this only works if you are using the "classic" authenticate_user! before action, and not when using authenticated routes. If you are using authenticated routes in your config/routes.rb, such as:

    authenticate :user do
      resources :some_resources
    end
    

    Prepending the action does not seem to affect the Devise chain in time, so you should comment out the authenticate block out, use an authenticate_user! before action instead in your app/controllers/application_controller.rb, and add a prepend action that sets skip_trackable to true in a specific controller.

提交回复
热议问题