Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make passwords optional using Devise?

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

like image 406
Fizz Avatar asked Nov 22 '25 04:11

Fizz


1 Answers

Found in the devise email group by Nat Budin:

class User < ActiveRecord::Base 
  devise :database_authenticatable, :validatable 
  protected 
  def password_required? 
    false 
  end 
end 
like image 168
cemregr Avatar answered Nov 23 '25 22:11

cemregr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!