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

后端 未结 4 1138
孤城傲影
孤城傲影 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条回答
  •  猫巷女王i
    2020-12-15 20:00

    Your code for time left is incorrect. The right calculation will be:

    def check_time_until_logout
      @time_left = Devise.timeout_in.seconds - (Time.now.to_i - user_session["last_request_at"]).round
    end
    

提交回复
热议问题