【发布时间】:2011-08-04 18:53:54
【问题描述】:
我正在尝试允许用户使用 twitter 等外部服务注册我的应用程序。因此,我不需要 Authlogic 尝试验证的用户模型的密码。结果,我禁用了密码验证,如下所示:
acts_as_authentic
before_validation :update_authlogic_config
#In the case that the user has signed up with an omniauth service.
attr_accessor :needs_no_password
def update_authlogic_config
validate_password_field = !needs_no_password
end
这一切都很好,但它似乎也禁用了我想要保留的电子邮件/用户名验证。
因此,我更新了我的方法以确保电子邮件字段验证如下:
def update_authlogic_config
validate_password_field = !needs_no_password
ignore_blank_passwords = needs_no_password
validate_email_field = true
end
使用它会拖回密码验证,给我以下错误:
密码太短(最少为 4 字符)
密码确认是 太短(最少 4 个字符)
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails validation passwords authlogic omniauth