user984621
user984621

Reputation: 48453

Rails 3 - Authlogic and expiration time on AJAX page

I have set up expiration time on 10 minutes. If I am idle more than these 10 minutes, so after click on a link in my admin section I will be redirected to login form with some flash message. This works me fine.

But now I solve a problem, when I am on a page that was called as AJAX (rendered by JS). If I am on this page idle more than 10 minutes and then I will click on a link in admin section, so I will get an error about missing ID (the reason is, because already doesn't exist session with ID - was destroyed after click on a link after 10 minutes idle).

Now I would like to about help, how to check, if I am on the AJAX page idle more than 10 minutes. I don't know, how to do this.

For usual checking I use in the controller followings:

acts_as_authentic do |c|
  c.logged_in_timeout(10.minutes)
end

Thank you in advance.

Upvotes: 0

Views: 193

Answers (1)

YvesR
YvesR

Reputation: 6222

Well I think you have two options.

You can setup a local javascript timer, which runs 10 minutes and then relocate your page.

Or

With every ajax request the controller server sided send a login error code which you handle in all your ajax call and redirect, if needed.

Upvotes: 1

Related Questions