I’m trying to allow users to sign up to my app with external services such as twitter etc. Consequently I don’t need a password for the user model which Authlogic tries to validate. As a result I’m disabling the password validations like so:
acts_as_authentic
before_validation :update_authlogic_config
#In the case that the user has signed up with an omniauth service.
attr_accessor :needs_no_password
def update_authlogic_config
validate_password_field = !needs_no_password
end
This all works well enough however it also seems to disable the email / username validations which I want to keep.
As a result, I updated my method to make sure the email field validates like so:
def update_authlogic_config
validate_password_field = !needs_no_password
ignore_blank_passwords = needs_no_password
validate_email_field = true
end
Using this it drags back in the password validations giving me the following errors:
Password is too short (minimum is 4
characters)Password confirmation is
too short (minimum is 4 characters)
Any ideas?
If you don’t put the crypted_password field in the User model you won’t get the Password module loaded and therefor the validations won’t run.
You’ll find this is the regular behaviour of each of the modules in Authlogic.