<commit_before><?php
/**
 * @author: KentProjects <<EMAIL>>
 * @license: Copyright KentProjects
 * @link: http://kentprojects.com
 */
class Authentication_Confirm extends Authentication_Abstract
{
	/**
	 * @var string
	 */
	protected $authentication = Auth::APP;

	/**
	 * The main action this authentication provider uses.
	 *
	 * @throws HttpStatusException
	 * @return void
	 */
	public function action()
	{
		if ($this->request->post("auth") === null)
		{
			throw new HttpStatusException(400, "Missing state code.");
		}
		
		$user = $this->validateCode();
		if (empty($user))
		{
			throw new HttpStatusException(400, "Invalid authentication token.");
		}
		
		$this->clearCode();
		
		$output = array(
			"token" => $this->createApiToken($user),
			"user" => $user
		);
		$this->response->status(200);
		$this->response->body(json_encode($output));
	}
	
	/**
	 * @return void
	 */
	private function clearCode()
	{
		Database::prepare("DELETE FROM `Authentication` WHERE `token` = ?", "s")->execute($this->request->query("auth"));
	}
	
	/**
	 * @return Model_User
	 */
	private function validateCode()
	{
		$statement = Database::prepare("SELECT `user_id` FROM `Authentication` WHERE `token` = ?", "s");
		$user_id = $statement->execute($this->request->post("auth"))->singleval();
		return (empty($user_id)) ? null : Model_User::getById($user_id);
	}
}<commit_msg>Fixed.<commit_after><?php
/**
 * @author: KentProjects <<EMAIL>>
 * @license: Copyright KentProjects
 * @link: http://kentprojects.com
 */
class Authentication_Confirm extends Authentication_Abstract
{
	/**
	 * @var string
	 */
	protected $authentication = Auth::APP;

	/**
	 * The main action this authentication provider uses.
	 *
	 * @throws HttpStatusException
	 * @return void
	 */
	public function action()
	{
		if ($this->request->post("code") === null)
		{
			throw new HttpStatusException(400, "Missing state code.");
		}
		
		$user = $this->validateCode();
		if (empty($user))
		{
			throw new HttpStatusException(400, "Invalid authentication token.");
		}
		
		$this->clearCode();
		
		$output = array(
			"token" => $this->createApiToken($user),
			"user" => $user
		);
		$this->response->status(200);
		$this->response->body(json_encode($output));
	}
	
	/**
	 * @return void
	 */
	private function clearCode()
	{
		Database::prepare("DELETE FROM `Authentication` WHERE `token` = ?", "s")->execute($this->request->query("auth"));
	}
	
	/**
	 * @return Model_User
	 */
	private function validateCode()
	{
		$statement = Database::prepare("SELECT `user_id` FROM `Authentication` WHERE `token` = ?", "s");
		$user_id = $statement->execute($this->request->post("auth"))->singleval();
		return (empty($user_id)) ? null : Model_User::getById($user_id);
	}
}
{'fraction_non_alphanumeric': 0.18551042810098792, 'fraction_numerical': 0.006586169045005488, 'mean_word_length': 4.119850187265918, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 43, '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': '2344349', 'n_tokens_mistral': 957, 'n_tokens_neox': 847, 'n_words': 180}