使用authlogic时,不允许在密码字段中输入空格

问题描述:

我在我的Rails应用程序中使用authlogic作为我的用户登录功能。但authlogic允许在密码空间,我的应用程序不需要这个。那我该怎么做呢?使用authlogic时,不允许在密码字段中输入空格

谢谢!

+0

目前还不清楚您是否关心在用户创建时或验证时验证密码格式。你可能会发现这个问题的答案有帮助:http://*.com/questions/2186831/validating-password-format-in-authlogic – bjg 2010-07-16 12:57:03

您可以使用正则表达式来定义密码规则。

validates_format_of :password, :with => /{regular expression here}/, :if => :require_password?, :message => "Must not contain any spaces!"