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 .
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.
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].
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With