不久前我也在问同样的问题。如果您想真正深入研究并花一些时间进行身份验证,请自己制作。但是,如果您想快速获得一些相当标准的东西,以便您可以专注于您的应用程序的功能,我建议您设计。
默认情况下,Lockable 模块似乎也没有打开,但无论哪种方式都可以轻松完成。
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
...
end
此外,如果您确实使用了 Lockable 模块,因为锁定是基于多次失败的身份验证尝试,您可以在触发锁定之前更改最大尝试次数config/initializers/devise.rb
Devise.setup do |config|
...
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
config.maximum_attempts = 20
...
end
只需快速阅读https://github.com/plataformatec/devise#devise