<commit_before>package pl.softwaremill.bootstrap.service

import pl.softwaremill.bootstrap.dao.UserDAO
import pl.softwaremill.bootstrap.domain.User
import pl.softwaremill.bootstrap.common.Utils

class UserService(userDAO: UserDAO) {

  def load(userId: Int) = {
    userDAO.load(userId)
  }

  def loadAll = {
    userDAO.loadAll
  }

  def count(): Long = {
    userDAO.count()
  }

  def registerNewUser(user: User) {
    userDAO.add(user)
  }

  def authenticate(login: String, nonEncryptedPassword: String): Option[User] = {
    userDAO.findBy((u: User) => (u.login.equalsIgnoreCase(login) && u.password.eq(Utils.sha256(nonEncryptedPassword, login))))
  }

  def authenticateWithToken(token: String): Option[User] = {
    userDAO.findBy((u: User) => u.token.equals(token))
  }

  def findByLogin(login: String): Option[User] = {
    userDAO.findBy((u: User) => u.login.equals(login))
  }

}
<commit_msg>Fixed password matching in UserService<commit_after>package pl.softwaremill.bootstrap.service

import pl.softwaremill.bootstrap.dao.UserDAO
import pl.softwaremill.bootstrap.domain.User
import pl.softwaremill.bootstrap.common.Utils

class UserService(userDAO: UserDAO) {

  def load(userId: Int) = {
    userDAO.load(userId)
  }

  def loadAll = {
    userDAO.loadAll
  }

  def count(): Long = {
    userDAO.count()
  }

  def registerNewUser(user: User) {
    userDAO.add(user)
  }

  def authenticate(login: String, nonEncryptedPassword: String): Option[User] = {
    userDAO.findBy((u: User) => (u.login.equalsIgnoreCase(login) && u.password.equals(Utils.sha256(nonEncryptedPassword, u.login))))
  }

  def authenticateWithToken(token: String): Option[User] = {
    userDAO.findBy((u: User) => u.token.equals(token))
  }

  def findByLogin(login: String): Option[User] = {
    userDAO.findBy((u: User) => u.login.equals(login))
  }

}

{'fraction_non_alphanumeric': 0.14146341463414633, 'fraction_numerical': 0.0032520325203252032, 'mean_word_length': 4.214689265536723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1377444', 'n_tokens_mistral': 670, 'n_tokens_neox': 645, 'n_words': 106}