<commit_before>require 'digest/sha1'

class User < ActiveRecord::Base
  include Authentication
  include Authentication::ByPassword
  include Authentication::ByCookieToken
  
  has_many  :service_subscriptions, :dependent => :destroy
  has_many  :garbage_subscriptions, :dependent => :destroy
  
  has_many  :services, :through => :service_subscriptions
  
  before_validation :prepare_params
  
  before_save :send_verification_if_required
  before_update :password_change_checks
  
  validates_presence_of     :login
  validates_length_of       :login,    :within => 3..40
  validates_uniqueness_of   :login
  validates_format_of       :login,    :with => Authentication.login_regex, :message => Authentication.bad_login_message

  validates_presence_of     :email
  validates_length_of       :email,    :within => 6..100 #<EMAIL>
  validates_uniqueness_of   :email
  validates_format_of       :email,    :with => Authentication.email_regex, :message => Authentication.bad_email_message

  validates_presence_of     :phone_number<commit_msg>Adding uniqueness back to the phone number now that the save issues are resolved.  This was causing an error when an existing number was used to create an account.<commit_after>require 'digest/sha1'

class User < ActiveRecord::Base
  include Authentication
  include Authentication::ByPassword
  include Authentication::ByCookieToken
  
  has_many  :service_subscriptions, :dependent => :destroy
  has_many  :garbage_subscriptions, :dependent => :destroy
  
  has_many  :services, :through => :service_subscriptions
  
  before_validation :prepare_params
  
  before_save :send_verification_if_required
  before_update :password_change_checks
  
  validates_presence_of     :login
  validates_length_of       :login,    :within => 3..40
  validates_uniqueness_of   :login
  validates_format_of       :login,    :with => Authentication.login_regex, :message => Authentication.bad_login_message

  validates_presence_of     :email
  validates_length_of       :email,    :within => 6..100 #<EMAIL>
  validates_uniqueness_of   :email
  validates_format_of       :email,    :with => Authentication.email_regex, :message => Authentication.bad_email_message

  validates_uniqueness_of   :phone_number
  validates_presence_of     :phone_number
{'fraction_non_alphanumeric': 0.0697980684811238, 'fraction_numerical': 0.007023705004389816, 'mean_word_length': 4.531553398058253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '2925333', 'n_tokens_mistral': 704, 'n_tokens_neox': 679, 'n_words': 149}