Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created November 13, 2013 13:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josevalim/1c3fb13862ae17a45acb to your computer and use it in GitHub Desktop.
Save josevalim/1c3fb13862ae17a45acb to your computer and use it in GitHub Desktop.
# Put this inside config/initializers/devise_paranoid_fix.rb
require 'devise/strategies/database_authenticatable'
Devise::Strategies::DatabaseAuthenticatable.class_eval do
def authenticate!
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
encrypted = false
if validate(resource){ encrypted = true; resource.valid_password?(password) }
resource.after_database_authentication
success!(resource)
end
mapping.to.new.password = password if !encrypted && Devise.paranoid
fail(:not_found_in_database) unless resource
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment