Skip to content

Instantly share code, notes, and snippets.

@bjensen
Forked from moeffju/user.rb
Created August 3, 2013 18:25
Show Gist options
  • Save bjensen/6147466 to your computer and use it in GitHub Desktop.
Save bjensen/6147466 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
alias :devise_valid_password? :valid_password?
def valid_password?(password)
begin
devise_valid_password?(password)
rescue BCrypt::Errors::InvalidHash
return false unless Digest::SHA1.hexdigest(password) == encrypted_password
logger.info "User #{email} is using the old password hashing method, updating attribute."
self.password = password
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment