Skip to content

Instantly share code, notes, and snippets.

@nerdyworm
Created November 8, 2013 21:45
Show Gist options
  • Save nerdyworm/7378186 to your computer and use it in GitHub Desktop.
Save nerdyworm/7378186 to your computer and use it in GitHub Desktop.
change password hashing on the fly gist
def valid_password?(incoming_password)
result = super incoming_password
if !result
# try old encryptor during transition
digest = Devise::Encryptors::CakeLegacy.digest(incoming_password, self.class.stretches, self.password_salt, self.class.pepper)
result = Devise.secure_compare(digest, self.encrypted_password)
if result
# update password to use new encryptor when there is a match
self.password = incoming_password
self.save
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment