我正在使用设计的可验证模块,而devise.rb
已编写 config.password_length = 10..128 ,但在登录时未验证密码长度。需要停止用户如果密码不在指定的密码长度之间,则登录。
请帮忙。
提前致谢。
答案 0 :(得分:0)
此选项不会影响登录。它会验证保存记录时用户的密码长度应介于8到128个字符之间。
<强>更新强>
如果您想阻止某人登录,则需要覆盖active_for_authentication?
class User
def active_for_authentication?
super && password_is_long_enough?
end
def password_is_long_enough?
# logic to check password is long enough
end
end
但是,由于密码是经过哈希处理的,因此您不知道它有多长时间,因此我不确定这会对您有所帮助:(