DevisePasswordHistory
This extension provides password history support for Devise, which allows you to prevent users from re-using the same password they've used in the past (the actual limit is configurable).
Installation
Add this line to your application's Gemfile:
gem 'devise_password_history'
And then execute:
$ bundle
Or install it yourself as:
$ gem install devise_password_history
Usage
After installation, you need to "install" the extension into your app via the following command:
$ bundle exec rails g devise_password_history:install
That generator will do three things:
- Modifies the
config/initializers/devise.rbfile with two new config options:config.deny_old_passwords: turns the validations on/offconfig.password_history_count: the threshold of how many passwords to store
- Creates an
OldPasswordpolymorphic model inapp/models - Creates the migration for the
old_passwordstable
So once you run the generator, you just need to:
$ bundle exec rake db:migrate
Now the extension has been installed. To use it, you tell devise like with
any of the other extensions:
class User < ActiveRecord::Base
devise :database_authenticatable, :password_history
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request