Dylan Richards
Dylan Richards

Reputation: 786

Disable password validation

If it's seen that a user is trying to log in with Facebook, I'd like to not require a password when logging in. However, the Authlogic (obviously) checks for a password when logging in. How can I disable password validation in this case?

Below is a short code snippet of the code that I'm working with. login_params changes depending on the method by which the user is logging in -- either by form fields or by OmniAuth.

login_params = if facebook_login?
   if homeowner = get_facebook_user
       {
       email: homeowner.email,
       password: homeowner.password
       }
       end
    else
       user_session_params
       end

Upvotes: 1

Views: 110

Answers (1)

roc
roc

Reputation: 2909

You could use a lambda in the validation to run it conditionally. For example:

validates :password, presence: true, if: lambda { !isNotFacebookLogin? }

Upvotes: 1

Related Questions