사용자 세션이 만료되었는지 여부를 주기적으로 확인하고 로그인 페이지로 리디렉션 할 수있는 솔루션을 찾고 있습니다.
필자는 Authlogic gem을 사용하고 있습니다. 따라서 current_user에 대한 테스트를 수행하는 함수를 호출하고 있습니다.
내 USER_SESSION_TIMEOUT이 5 분이므로 매 5 분마다이 ajax를 호출합니다. Ruby on Rail - Authlogic : 주기적으로 사용자 세션이 유효한지 확인하십시오.
def check_session_timed_out
if !current_user
flash[:login_notice] = "Your session timed out due to a period of inactivity. Please sign in again."
render :update do |page|
page.redirect_to "/user_sessions/new"
end
else
render :nothing => true
end
end
<%= periodically_call_remote :url => {:controller => 'user_session', :action => 'check_session_timed_out'}, :frequency => (USER_SESSION_TIMEOUT + 10.seconds) %>
은 내가 사용자 개체 CURRENT_USER 호출 할 때마다 업데이트되는 것으로 나타났습니다 그래서 세션은 5 분으로 갱신됩니다.
하나의 탭만 열려도 문제가되지 않지만 check_session_timed_out을 호출 할 때마다 2 개의 탭이있는 경우 current_user는 사용자를 갱신하므로 세션이 만료되지 않습니다.
어떤 아이디어가 있습니까? 감사
AuthLogic source itself에서
MERCI! 저건 완벽 해 – Mathieu