<commit_before>class User < ActiveRecord::Base
  belongs_to :website
  has_many :orders, :order => 'created_at DESC', :dependent => :nullify
  
  # unencrypted password
  attr_accessor :password
  
  attr_protected :admin, :manages_website_id, :website_id

  # associations
  belongs_to :managed_website, :foreign_key => :manages_website_id, :class_name => 'Website'

  # validation
  validates_length_of     :email, :within => 3..100
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
  validates_uniqueness_of :email, :case_sensitive => false, :message => 'has already been taken. If you have forgotten your password you can request a new one.'
  
  validates_presence_of   :name
  validates_length_of     :password, :within => 4..40,
                                     :if => :password_required?
  validates_confirmation_of :password, :if => :password_required?
  
  # callbacks
  before_save :encrypt_password

  # encrypts given password using salt
  def self.encrypt(pass, salt)<commit_msg>Delete addresses when user is deleted<commit_after>class User < ActiveRecord::Base
  belongs_to :website
  has_many :orders, :order => 'created_at DESC', :dependent => :nullify
  has_many :addresses, :dependent => :delete_all

  # unencrypted password
  attr_accessor :password
  
  attr_protected :admin, :manages_website_id, :website_id

  # associations
  belongs_to :managed_website, :foreign_key => :manages_website_id, :class_name => 'Website'

  # validation
  validates_length_of     :email, :within => 3..100
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
  validates_uniqueness_of :email, :case_sensitive => false, :message => 'has already been taken. If you have forgotten your password you can request a new one.'
  
  validates_presence_of   :name
  validates_length_of     :password, :within => 4..40,
                                     :if => :password_required?
  validates_confirmation_of :password, :if => :password_required?
  
  # callbacks
  before_save :encrypt_password

  # encrypts given password using salt
  def self.encrypt(pass, salt)
{'fraction_non_alphanumeric': 0.12177985948477751, 'fraction_numerical': 0.00936768149882904, 'mean_word_length': 3.910344827586207, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '3260344', 'n_tokens_mistral': 735, 'n_tokens_neox': 694, 'n_words': 168}