module Clearance::User::ClassMethods

@api private

Constants

DUMMY_PASSWORD

Public Instance Methods

authenticate(email, password) click to toggle source
# File lib/clearance/user.rb, line 115
def authenticate(email, password)
  if user = find_by_normalized_email(email)
    if password.present? && user.authenticated?(password)
      user
    end
  else
    prevent_timing_attack
  end
end
find_by_normalized_email(email) click to toggle source
# File lib/clearance/user.rb, line 125
def find_by_normalized_email(email)
  find_by(email: normalize_email(email))
end
normalize_email(email) click to toggle source
# File lib/clearance/user.rb, line 129
def normalize_email(email)
  email.to_s.downcase.gsub(/\s+/, "")
end

Private Instance Methods

password_strategy() click to toggle source
# File lib/clearance/user.rb, line 142
def password_strategy
  Clearance.configuration.password_strategy || PasswordStrategies::BCrypt
end
prevent_timing_attack() click to toggle source
# File lib/clearance/user.rb, line 137
def prevent_timing_attack
  new(password: DUMMY_PASSWORD)
  nil
end