<commit_before><?php

namespace Moulino\Framework\Auth;

use Moulino\Framework\Service\Container;
use Moulino\Framework\Model\ModelInterface;
use Moulino\Framework\Auth\Exception\BadCredentialsException;

abstract class AbstractAuthenticator implements AuthenticatorInterface
{
	protected $translator;
	protected $model;
	protected $passwordEncoder;

	const LOCKED_USER_MESSAGE  = "Account locked";
	const UNKNOWN_USER_MESSAGE = "Unknown username";
	const WRONG_PASSWORD       = "<PASSWORD>";
	const USER_NOT_LOGGED      = "User is not logged";

	public function __construct(Container $container, ModelInterface $model) {
		$this->translator = $container->get('translator');
		$this->passwordEncoder = $container->get('password_encoder');
		$this->model = $model;
	}

	protected function fetchUser($user_id) {
		$user = $this->model->get(array('user_id' => $user_id));

		if(!$user) {
			throw new BadCredentialsException($this->translator->tr(self::UNKNOWN_USER_MESSAGE), 403);
		}

		if($user['errors'] >= 10) {
			throw new BadCredentialsException($this->translator->tr(self::LOCKED_USER_MESSAGE), 403);
		}

		return $user;
	}
	
	/**
	 * Return the password encoded
	 * @param string ununcrypted password
	 * @return string encrypted password
	 */
	protected function encodePassword($password) {
		return $this->passwordEncoder->encode($password);
	}

}<commit_msg>Updates<commit_after><?php

namespace Moulino\Framework\Auth;

use Moulino\Framework\Service\Container;
use Moulino\Framework\Model\ModelInterface;
use Moulino\Framework\Auth\Exception\BadCredentialsException;

abstract class AbstractAuthenticator implements AuthenticatorInterface
{
	protected $translator;
	protected $model;
	protected $passwordEncoder;

	const LOCKED_USER_MESSAGE  = "Account locked";
	const UNKNOWN_USER_MESSAGE = "Unknown username";
	const WRONG_PASSWORD       = "<PASSWORD>";
	const USER_NOT_LOGGED      = "User is not logged";

	public function __construct(Container $container, ModelInterface $model) {
		$this->translator = $container->get('translator');
		$this->passwordEncoder = $container->get('password_encoder');
		$this->model = $model;
	}

	protected function fetchUser($user_id) {
		$user = $this->model->get(array('user_id' => $user_id));

		if(!$user) {
			throw new BadCredentialsException($this->translator->tr(self::UNKNOWN_USER_MESSAGE), 403);
		}

		if($user['errors'] >= 10) {
			throw new BadCredentialsException($this->translator->tr(self::LOCKED_USER_MESSAGE), 403);
		}

		return $user;
	}
	
	/**
	 * Return the password encoded
	 * @param string ununcrypted password
	 * @return string encrypted password
	 */
	public function encodePassword($password) {
		return $this->passwordEncoder->encode($password);
	}

}
{'fraction_non_alphanumeric': 0.1282521069989007, 'fraction_numerical': 0.005862953462806889, 'mean_word_length': 5.484560570071259, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '2212830', 'n_tokens_mistral': 876, 'n_tokens_neox': 812, 'n_words': 170}