<commit_before>module Carto
  module UserAuthenticator
    def authenticate(email, password)
      sanitized_input = email.strip.downcase
      if candidate = ::User.filter("email = ? OR username = ?", sanitized_input, sanitized_input).first
        check_password_locked(candidate)
        return candidate if valid_password?(candidate, password)
      end
    end

    def valid_password?(candidate, password)
      candidate.crypted_password == password_digest(password, candidate.salt)
    end

    def check_password_locked(user)
      retry_after = user.password_login_attempt
      if retry_after != ::User::LOGIN_NOT_RATE_LIMITED
        throw(:warden, action: :password_locked, retry_after: retry_after)
      end
    end

    def password_digest(password, salt)<commit_msg>change method name<commit_after>module Carto
  module UserAuthenticator
    def authenticate(email, password)
      sanitized_input = email.strip.downcase
      if candidate = ::User.filter("email = ? OR username = ?", sanitized_input, sanitized_input).first
        login_attempt(candidate)
        return candidate if valid_password?(candidate, password)
      end
    end

    def valid_password?(candidate, password)
      candidate.crypted_password == password_<PASSWORD>(password, candidate.<PASSWORD>)
    end

    def login_attempt(user)
      retry_after = user.password_login_attempt
      if retry_after != ::User::LOGIN_NOT_RATE_LIMITED
        throw(:warden, action: :password_locked, retry_after: retry_after)
      end
    end

    def password_digest(password, salt)
{'fraction_non_alphanumeric': 0.0817891373801917, 'fraction_numerical': 0.0, 'mean_word_length': 3.7889908256880735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '222021', 'n_tokens_mistral': 458, 'n_tokens_neox': 444, 'n_words': 97}