<commit_before>package pl.softwaremill.bootstrap.domain

import pl.softwaremill.bootstrap.common.Utils
import org.bson.types.ObjectId

case class User(id: ObjectId, login: String, loginLowerCased: String, email: String, password: String, salt: String,
                token: String)

object User {

  def apply(login: String, email: String, plainPassword: String, salt: String, token: String) = {
    new User(null, login, login.toLowerCase, email, encryptPassword(plainPassword, salt), salt, token)
  }

  def encryptPassword(password: String, salt: String) = {
    Utils.sha256(password, salt)
  }

  def passwordsMatch(plainPassword: String, user: User) = {
    user.password.equals(encryptPassword(plainPassword, user.salt))
  }
}<commit_msg>It doesnt matter whether id is generated on the client or in the db, part of #50<commit_after>package pl.softwaremill.bootstrap.domain

import pl.softwaremill.bootstrap.common.Utils
import org.bson.types.ObjectId

case class User(id: ObjectId, login: String, loginLowerCased: String, email: String, password: String, salt: String,
                token: String)

object User {

  def apply(login: String, email: String, plainPassword: String, salt: String, token: String) = {
    new User(new ObjectId, login, login.toLowerCase, email, encryptPassword(plainPassword, salt), salt, token)
  }

  def encryptPassword(password: String, salt: String) = {
    Utils.sha256(password, salt)
  }

  def passwordsMatch(plainPassword: String, user: User) = {
    user.password.equals(encryptPassword(plainPassword, user.salt))
  }
}
{'fraction_non_alphanumeric': 0.10848755583918315, 'fraction_numerical': 0.005105296745373325, 'mean_word_length': 4.681159420289855, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1091230', 'n_tokens_mistral': 479, 'n_tokens_neox': 453, 'n_words': 133}