❤️ Provides automatic session timeout in a Rails application.
MIT License
By Thadeu Esteves Jr.
Provides automatic session timeout in a Rails application. Very easy to install and configure. Have you ever wanted to force your users off your app if they go idle for a certain period of time? Many online banking sites use this technique. If your app is used on any kind of public computer system, this plugin is a necessity.
Rails Automatic Logout works only Rails 4. You can add it to your Gemfile with:
gem 'rails-automaticlogout', '~> 0.1'
Then run bundle install
After installing, add in your application controller, ex:
class ApplicationController < ActionController::Base
before_action :authenticate_user!
# by default is time 1.hour
automatic_logout_at
end
By default the time is 1.hour
class ApplicationController < ActionController::Base
before_action :authenticate_user!
# by default is time 1.hour
automatic_logout_at time: 5.minutes
end
class ApplicationController < ActionController::Base
before_action :authenticate_user!
# by default is time 1.hour
automatic_logout_at time: 12.hour,
message: 'Session expired! You will be redirect.'
end
Add in your application.js this require
//= require automatic_logout
Use Helper in your view, for show regressive timer. Add this in your file application.html.erb
<%= regressive_timer %>
We have a long list of valued contributors. Check them all at: https://github.com/Thadeu/rails-automaticlogout.