Разработать - сделать запрос без сброса обратного отсчета, пока пользователь не выйдет из-за неактивности
я работаю над приложением RoR с Devise. Я хочу разрешить клиентам отправлять запрос на сервер, чтобы узнать, сколько времени осталось до автоматического выхода пользователя на клиенте из-за неактивности (используяTimeoutable
модуль). Я нене хочу, чтобы этот запрос заставлял Devise сбрасывать обратный отсчет, пока пользователь не выйдет из системы. Как я могу настроить это?
Вот код, который у меня есть сейчас:
class SessionTimeoutController < ApplicationController
before_filter :authenticate_user!
# Calculates the number of seconds until the user is
# automatically logged out due to inactivity. Unlike most
# requests, it should not reset the timeout countdown itself.
def check_time_until_logout
@time_left = current_user.timeout_in
end
# Determines whether the user has been logged out due to
# inactivity or not. Unlike most requests, it should not reset the
# timeout countdown itself.
def has_user_timed_out
@has_timed_out = current_user.timedout? (Time.now)
end
# Resets the clock used to determine whether to log the user out
# due to inactivity.
def reset_user_clock
# Receiving an arbitrary request from a client automatically
# resets the Devise Timeoutable timer.
head :ok
end
end
SessionTimeoutController#reset_user_clock
работает, потому что каждый раз, когда RoR получает запрос от аутентифицированного пользователя,Timeoutable#timeout_in
сбрасывается на то, что я настроил вDevise#timeout_in
, Как предотвратить этот сброс вcheck_time_until_logout
а также ?has_user_timed_out