Temporarily disable password validation in AuthLogic at runtime
I needed to create a bunch of users, some by setting a password and some by skipping password validation because they already have a crypted_password and password_salt (AuthLogic’s default password storage fields). I Googled all over the place for a solution to hack AuthLogic, then hack Rails validators, but finally found one from looking at the source.
You can monkey patch AuthLogic’s require_password? method to return false and the password authentication check will be skipped. So in the part of my script right before importing users that already had a crypted password I added the following:
class User def require_password? false end end
The validator itself is still present on User, but luckily AuthLogic adds an :if => require_password? check to it. Manipulating that check lets you skip validation altogether.
















