ruby-on-railsauthlogic

updating authlogic not recognizing old previous passwords


I was using authlogic 3.0.0 when using rails 3.2.2. Now i have updated rails version to 5.1.4. And authlogic upgraded to 4.0.1.

Now all of my previously saved passwords are not recognizing by authlogic. It says invalid password. So i have to update my password again. WHich is no desirable behavior. What changes i need to do so that my previously saved passwords work again on new authlogic version.

Any help would be appreciated.


Solution

  • Here is how i solve my issue,

    User.rb

      acts_as_authentic do |c|
        c.crypto_provider = Authlogic::CryptoProviders::Sha512
      end
    

    In version 3.4.0, the default crypto_provider was changed from Sha512 to SCrypt.

    If you never set a crypto_provider and are upgrading, your passwords will break unless you set the original:

    c.crypto_provider = Authlogic::CryptoProviders::Sha512
    

    And if you want to automatically upgrade from Sha512 to SCrypt as users login:

    c.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512]
    c.crypto_provider = Authlogic::CryptoProviders::SCrypt