The developer has a built-in solution with the option :lockable in Lock locked documentation
You must set the lock_strategy parameter to :failed_attempts.
Step 1 Configure / initializers / devise.rb to use:
Step 2 For this you should add a lockable model:
class Example < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :lockable
Step 3 Create a migration to do development work
class AddLockableToExamples < ActiveRecord::Migration def change add_column :examples, :failed_attempts, :integer, default: 0 add_column :examples, :unlock_token, :string add_column :examples, :locked_at, :datetime end end
Best wishes!!
felipeclopes
source share