0

在设计中使用可锁定模块时,为什么failed_attempts字段没有增加?我的设置有问题吗?failed_attempts当登录失败且密码错误时,不会从 0 开始移动。

路线.rb

devise_for :users, controllers: { registrations: 'users/registrations' }
devise_for :admins, controllers: { registrations: 'admins/registrations' }, skip: [:sessions]

架构.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

用户.rb

devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :lockable, remember_for: 4.weeks

管理员.rb

devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :lockable, :timeoutable, timeout_in: 60.minutes

设计.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
4

0 回答 0