如何使密码可选的使用设计? [英] How to make passwords optional using Devise?

查看:101
本文介绍了如何使密码可选的使用设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能使密码可选进入注册和验证用户在使用设计(如果没有密码,那么它将只使用电子邮件)登录。尽管如果他们用密码进行注册(或更高版本更新),它应该然后就需要登录。我怎样才能做到这一点使用设计?

How can I make the password optional into the registration and login when authenticating a user (if no password then it will just use the e-mail) using Devise. Although if they register with a password (or update it later) it should then be require for login. How can I accomplish this using Devise?

请注意:我使用的Rails 3.0.1,并制定1.1.rc0

Note: I'm using Rails 3.0.1 and Devise 1.1.rc0

推荐答案

在<找到的href=\"http://groups.google.com/group/plataformatec-devise/browse_thread/thread/2a2d6760652f07a8/6560c822319fd42d\"相对=nofollow>由纳特Budin设计的电子邮件组:

class User < ActiveRecord::Base 
  devise :database_authenticatable, :validatable 
  protected 
  def password_required? 
    false 
  end 
end 

这篇关于如何使密码可选的使用设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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