<commit_before>class MmUser 
  include MongoMapper::Document

  email_regexp = /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i
  key :email, String, :unique => true, :format => email_regexp
  key :hashed_password, String
  key :salt, String
  key :permission_level, Integer, :default => 1
  if Sinatra.const_defined?('FacebookObject')
    key :fb_uid, String
  end

  timestamps!

  attr_accessor :password, :password_confirmation
  #protected equievelant? :protected => true doesn't exist in dm 0.10.0
  #protected :id, :salt
  #doesn't behave correctly, I'm not even sure why I did this.

  #validates_presence_of :password_confirmation, :unless => Proc.new { |t| t.hashed_password }
  validates_presence_of :password, :allow_blank => true
  validates_confirmation_of :password

  def password=(<PASSWORD>)
    @password = <PASSWORD>
    self.salt = User.random_string(10) if !self.salt
    self.hashed_password = User.encrypt(@password, self.salt)
  end

  def admin?
    self.permission_level == -1 || self.id == 1
  end

  def site_admin?
    self.id == 1
  end

  protected

  def method_missing(m, *args)
    return false
  end
end<commit_msg>Let app do validation<commit_after>class MmUser 
  include MongoMapper::Document

  email_regexp = /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i
  key :email, String, :unique => true, :format => email_regexp
  key :hashed_password, String
  key :salt, String
  key :permission_level, Integer, :default => 1
  if Sinatra.const_defined?('FacebookObject')
    key :fb_uid, String
  end

  timestamps!

  attr_accessor :password, :password_confirmation

  def password=(<PASSWORD>)
    @password = <PASSWORD>
    self.salt = User.random_string(10) if !self.salt
    self.hashed_password = <PASSWORD>.<PASSWORD>(<PASSWORD>, self.salt)
  end

  def admin?
    self.permission_level == -1 || self.id == 1
  end

  def site_admin?
    self.id == 1
  end

  protected

  def method_missing(m, *args)
    return false
  end
end
{'fraction_non_alphanumeric': 0.14550928248871048, 'fraction_numerical': 0.011038635223281485, 'mean_word_length': 3.816425120772947, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2337808', 'n_tokens_mistral': 752, 'n_tokens_neox': 702, 'n_words': 169}