<commit_before>class User < ActiveRecord::Base
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

  before_save {self.email = email.downcase}

  has_many :favorites
  has_many :tattoos

  validates :name, presence: true, length: {maximum: 50}
  validates :email, presence: true, length: {maximum: 255}, 
            format: { with: VALID_EMAIL_REGEX },
            uniqueness: {case_sensitive: false}
  validates :password, confirmation: true, presence: true, length: {minimum: 6}
  validates :password_confirmation, presence: true, length: {minimum: 6}

  has_secure_password

  # returns the hash digest for a given string
  def User.digest(string)  
    cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
                                                  BCrypt::Engine::cost
    BCrypt::Password.create(string, cost: cost)
  end
  
end<commit_msg>Add new_token method to user model, generates a random token.<commit_after>class User < ActiveRecord::Base
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

  before_save {self.email = email.downcase}

  has_many :favorites
  has_many :tattoos

  validates :name, presence: true, length: {maximum: 50}
  validates :email, presence: true, length: {maximum: 255}, 
            format: { with: VALID_EMAIL_REGEX },
            uniqueness: {case_sensitive: false}
  validates :password, confirmation: true, presence: true, length: {minimum: 6}
  validates :password_confirmation, presence: true, length: {minimum: 6}

  has_secure_password

  # returns the hash digest for a given string
  def User.digest(string)  
    cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
                                                  BCrypt::Engine::cost
    BCrypt::Password.create(string, cost: cost)
  end

  # returns a random token
  def User.new_token
    SecureRandom.urlsafe_base64
  end

end
{'fraction_non_alphanumeric': 0.11860832894043226, 'fraction_numerical': 0.008434370057986295, 'mean_word_length': 3.1350762527233114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1258153', 'n_tokens_mistral': 633, 'n_tokens_neox': 589, 'n_words': 152}