Sha256: 46e4e4e06e8497a076ef4676bf5a5e2cc0f94964362c14ec65dd4808a05e4d4d

Contents?: true

Size: 869 Bytes

Versions: 4

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require 'devise/strategies/authenticatable'

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

Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabaseAuthenticatable)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-4.4.3 lib/devise/strategies/database_authenticatable.rb
devise-4.4.2 lib/devise/strategies/database_authenticatable.rb
devise-4.4.1 lib/devise/strategies/database_authenticatable.rb
devise-4.4.0 lib/devise/strategies/database_authenticatable.rb