Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatic logout after inactivity/idle

Tags:

How to set up in the rails application that if any user is idle for 30 minutes or a specific period of time he should be automatically get logged out. Can any one give any solution . i am using devise for authentication purpose. Any help is appreciated .

like image 446
Sam Avatar asked Jan 29 '13 07:01

Sam


People also ask

How do I stop inactivity logout?

Go to Advanced power settings (click on Windows button, write power options, click on Power Options, in the selected plan click on the Change plan settings, click on the Change advanced power settings). 9. Click Sleep, then System unattended sleep timeout, then change these settings from 2 Minutes to 20 for example.

What is auto logout?

After you log in, the machine automatically logs you out if you do not use the control panel within a given time. This feature is called "Auto Logout". Specify how long the machine is to wait before performing Auto Logout. Log in as the machine administrator from the control panel. Press [System Settings].


1 Answers

You should use Timeoutable model trait.

Timeoutable takes care of veryfing whether a user session has already expired or not. When a session expires after the configured time, the user will be asked for credentials again, it means, he/she will be redirected to the sign in page.

Options

Timeoutable adds the following options to devise_for:

  • +timeout_in+: the interval to timeout the user session without activity.

In your model you need

devise :timeoutable # along with :database_authenticatable, :registerable and other things. 

Also, take a look at config/initializers/devise.rb, you can configure timeout value there.

like image 132
Sergio Tulentsev Avatar answered Oct 21 '22 05:10

Sergio Tulentsev