I'm migration users database from PHP to Rails. I have already instaled Devise Gem and it is working well now. Also, I have found a hint how to migrate existing users' passwords to Rails
I have added old passwords to same encrypted_password
field as Devise holds, so when devise fails to auth, checking for old password:
# user.rb
def valid_password?(password)
return false if encrypted_password.blank?
require 'digest/sha1'
password_salt = 'my_php_framework_salt'
Devise.secure_compare(Digest::SHA1.hexdigest(password_salt+password), self.encrypted_password)
end
It allows to login with old passwords, but doesn't work with original Devise passwords for new users. I think this valid_password?
method should return true
for devise passwords. How to fix this?