I have a password check for my User model and the create_with_omniauth method to retrieve information from a Facebook user account:
user.rb:
class User < ActiveRecord::Base attr_accessible :name, :email, :password, :password_confirmation has_secure_password validates :name, presence: true, length: { maximum: 50 } VALID_EMAIL_REGEX = /\A[\w+\-.] +@ [az\d\-.]+\.[az]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, presence: true, length: { minimum: 6 } validates :password_confirmation, presence: true def self.create_with_omniauth(auth) create! do |user| user.provider = auth["provider"] user.uid = auth["uid"] user.name = auth["info"]["name"] user.email = auth["info"]["email"] end end end
Now when I click link_to "Sign in with Facebook, "auth/facebook" , I get this error:
Verification failed: Password cannot be empty, password cannot be empty, Password is too short (minimum 6 characters), password confirmation cannot be empty
Due to these two lines in the User model:
validates :password, presence: true, length: { minimum: 6 } validates :password_confirmation, presence: true
How to get around this check when a user tries to log in using the OmniAuth login method?
source share