如何使用Ruby on Rails中的Devise验证密码强度? [英] How to validate password strength with Devise in Ruby on Rails?

查看:139
本文介绍了如何使用Ruby on Rails中的Devise验证密码强度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制用户在注册时选择一个强大的密码。

I want to force a user to choose a strong password on registration.

我知道,有很多jquery密码强度表,我最有可能也可以使用其中的一个。但是,这并没有真正强制任何人选择强大的密码。注册表单也可以在没有启用js的情况下使用,所以仍然可能会使用弱密码注册。

I know, there are many jquery password strength meters out there, and I will most probably use one of them, too. But that does not really enforce anyone to choose a strong password. The registration form must also be useable without js enabled, so one could still potentially register with a weak password.

帐户必须最安全,因为如果您登录,您可以看到其他帐户的数据,我不想在任何情况下暴露。所以我想在这里保证最大的安全性,所以我认为,最重要的是只允许强密码。

Accounts must be most secure, because if you are logged in, you can see data of other accounts, which I do not want exposed under any circumstances. So I want to go for maximum security here, therefore I think, it is most important to only allow strong passwords.

所以,

如何设置和自定义验证最低密码强度的要求?只有我可以在devise配置文件中找到的是密码长度。还有另外一个宝石,我应该用这个任务吗?

推荐答案

你可以使用 Devise Security扩展,您可以在其中定义密码正则表达式验证(除其他外),并强制您需要的密码强度。

You can use the Devise Security extension, where you can define a password regexp validation (among other things) and enforce the password strength you want.

这篇关于如何使用Ruby on Rails中的Devise验证密码强度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆