rails-automaticlogout

❤️ Provides automatic session timeout in a Rails application.

MIT License

Downloads
13.6K
Stars
11
Committers
3

Rails Automatic Logout

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.

  • Force your users power off session
  • show for they the regressive time

Getting started

Rails Automatic Logout works only Rails 4. You can add it to your Gemfile with:

gem 'rails-automaticlogout', '~> 0.1'

Then run bundle install

How to use?

Configure Controller

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

Change timeout value.

class ApplicationController < ActionController::Base
  before_action :authenticate_user!

  # by default is time 1.hour
  automatic_logout_at time: 5.minutes
end

Change message

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

Configure Javascript

Add in your application.js this require

//= require automatic_logout

Configure View (OPTIONAL)

Use Helper in your view, for show regressive timer. Add this in your file application.html.erb

<%= regressive_timer %>

TODO

  • Add translations
  • Add configurations for action_view
  • Add Suport for Rails 5.x
  • Setup test environment
  • Add Tests
  • Integrate automatic verification services (Travis-CI, Hakiri, CodeClimate, etc)

Contributing

We have a long list of valued contributors. Check them all at: https://github.com/Thadeu/rails-automaticlogout.

Package Rankings
Top 25.13% on Rubygems.org
Badges
Extracted from project README
Gem Version Code Climate