如何使用Devise使密码可选? [英] How to make passwords optional using Devise?
本文介绍了如何使用Devise使密码可选?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果使用Devise验证用户(如果没有密码,那么只是使用电子邮件),我如何将密码选择为注册和登录。虽然如果他们注册一个密码(或稍后更新),那么它应该需要登录。注意:我使用的是Rails 3.0.1和Devise 1.1.rc0
解决方案
找到:
class User< ActiveRecord :: Base
devise:database_authenticatable,:validatable
protected
def password_required?
false
end
end
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?
Note: I'm using Rails 3.0.1 and Devise 1.1.rc0
解决方案
Found in the devise email group by Nat Budin:
class User < ActiveRecord::Base
devise :database_authenticatable, :validatable
protected
def password_required?
false
end
end
这篇关于如何使用Devise使密码可选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文