Skip to content

Instantly share code, notes, and snippets.

@mctaylorpants
Created December 19, 2017 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mctaylorpants/afbe751bedf40f1b0e187b8b9c745721 to your computer and use it in GitHub Desktop.
Save mctaylorpants/afbe751bedf40f1b0e187b8b9c745721 to your computer and use it in GitHub Desktop.
module Devise
module Strategies
# Default strategy for signing in a user, based on their email and password in the database.
class DatabaseAuthenticatable < Authenticatable
def authenticate!
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
hashed = false
if validate(resource){ hashed = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end
mapping.to.new.password = password if !hashed && Devise.paranoid
fail(:not_found_in_database) unless resource
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment