skip password validation in authlogic

i am using authlogic for user authentication and authlogic-connect for
facebook and twitter signup.what i need is that i need to skip
validation on the password field if user is signup via facebook or
twitter.my environment is rails 3 and ruby 1.9.2.
i have acts_as_authentic in my user model.however i can skip phone
number validation like this
validates :phone_number, :numericality => true,:unless
=>Proc.new{|user|user.oauth_user}
def oauth_user
    self.authenticated_with?(:facebook) ||
self.authenticated_with?(:twitter)
end

i give like this
acts_as_authentic do |c|
c.require_password_confirmation=false :if
=>Proc.new{|user|user.oauth_user}
c.validate_password_field=false :if =>Proc.new{|user|user.oauth_user}
end

but it does't work.any help please?

acts_as_authentic do |c|
c.require_password_confirmation = false if c.oauth_user
c.validate_password_field = false if oauth_user
end

or

acts_as_authentic do |c|
   if c.oauth_user
c.require_password_confirmation = false
     c.validate_password_field = false
   end
end

caveat: I don't use Authlogic, so this is a bit of a stab from looking
at your code snippet... but it's what I'd try first :slight_smile:

Michael Pavling wrote in post #968500:

acts_as_authentic do |c|
c.require_password_confirmation=false :if
=>Proc.new{|user|user.oauth_user}
c.validate_password_field=false :if =>Proc.new{|user|user.oauth_user}
end

but it does't work.any help please?

acts_as_authentic do |c|
c.require_password_confirmation = false if c.oauth_user
c.validate_password_field = false if oauth_user
end

or

acts_as_authentic do |c|
   if c.oauth_user
    c.require_password_confirmation = false
    c.validate_password_field = false
   end
end

caveat: I don't use Authlogic, so this is a bit of a stab from looking
at your code snippet... but it's what I'd try first :slight_smile:

thanks for you replay but it gives me an error "undefined method
`oauth_user' for #<Class:0x00000005a63920>"

i have oauth_user method in my user model
def oauth_user
    self.authenticated_with?(:facebook) ||
self.authenticated_with?(:twitter)
end
this method will return facebook or twitter token if user is authorized
with facebook or twitter respectively.other wise it will return nil.
so i want to skip password validation unless this method return nil
value.any help please?