How to make Devise lockable with number of failed attempts

后端 未结 2 942
眼角桃花
眼角桃花 2020-12-05 00:17

Using Devise 2.1.2 and Rails 3.2.6

I\'m doing this Q&A just in case others run into this problem because I found little and scattered documentation for it.

2条回答
  •  隐瞒了意图╮
    2020-12-05 00:31

    Devise needs these three attributes on your model. Therefore, generate the following migration and run it.

    class AddLockableToExamples < ActiveRecord::Migration
      def change
        add_column :examples, :failed_attempts, :integer, default: 0
        add_column :examples, :unlock_token, :string # Only if unlock strategy is :email or :both
        add_column :examples, :locked_at, :datetime
      end
    end
    

    Hope this saves someone else hours of google-fu.

提交回复
热议问题