Deviseでロック可能なモジュールを使用すると、failed_attempts
フィールドが増加しないのはなぜですか? セットアップに何か問題がありますか? failed_attempts
不正なパスワードでログインに失敗した場合、0 から移動しません。
ルート.rb
devise_for :users, controllers: { registrations: 'users/registrations' }
devise_for :admins, controllers: { registrations: 'admins/registrations' }, skip: [:sessions]
schema.rb
create_table "admins", :force => true do |t|
...
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
...
end
create_table "users", :force => true do |t|
...
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
...
end
user.rb
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :lockable, remember_for: 4.weeks
admin.rb
devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :lockable, :timeoutable, timeout_in: 60.minutes
devise.rb
config.lock_strategy = :failed_attempts
config.unlock_keys = [ :email ]
config.unlock_strategy = :both
config.maximum_attempts = 3
config.unlock_in = 1.hour
バージョン
Rails 3.2.0
Ruby 1.9.3p194
Devise 2.1.2