Devise-Suspendable is a simple module which uses the Devise authentication framework Activatable module hooks to provide a simple clean way to suspend an account.
When an account is suspended the date and time of suspension is recorded, as well as an optional reason, for easy reference.
Either install it as a plugin:
script/plugin install firstname.lastname@example.org:joshk/devise_suspendable.git
or a gem (using any of the following)
sudo gem install devise_suspendablein your command prompt
config.gem devise_suspendablein environment.rb
gem devise_suspendableor in your Gemfile
And don't forget to add Devise!
Once devise-suspendable is installed, all you need to do is setup the user model which includes a small addition to the model itself and to the schema.
First the schema :
create_table :users do |t| t.suspendable end
and don’t forget to migrate :
then finally the model :
class User < ActiveRecord::Base devise :authenticatable, :trackable, :activatable, :suspendable # or :database_authenticatable in 1.1 ... end
Remember to include :activatable so the Activatable hook is included.
Devise-Imapable works in replacement of Authenticatable, allowing for user name (or email) and password authentication. The standard sign_in routes and views work out of the box as these are just reused from devise. I recommend you run :
so you can customize your login pages.
This plugin is similar to Lockable and can be used along side it, as long as Lockable is using token or timeouts as the unlock strategy.
Lockable is great for failed login tracking, and subsequent locking
Suspendable is best for manual account suspension
Maintaining your active users is part and parcel of running a web app
- tests, tests, tests
Released under the MIT license
Copyright (c) 2010 Josh Kalderimis,