<commit_before><?php

class LoginHandler{
	private $m_sessionLoggedIn = "loggedIn";
			
	/**
	 * Create temporary Users
	 */
	private $users = array("Fisk" => "Fisk22", "Fisken" => "Fisken22", "Sture" => "Sture22");	
	
	/**
	 * Create a error array
	 */
	public $errors = array();
	
	/**
	 * Any user logged in?
	 * 
	 * @return BOOLEAN, True = logged in, False = not logged in
	 */
	public function isLoggedIn() {
		if($_SESSION[$this->m_sessionLoggedIn]) {
			return true;
		}
		return false;
	}
	
	/**
	 * Logging in a user if the password is right.
	 * 
	 * @param $tryUser String, attempted username
	 * @param $tryPassword String, attempted password
	 * @return Boolean, True = Login success, False = Login Failed.
	 */
	public function doLogin($tryUser, $tryPassword) {
		
		/* 
		 * Creates a test for all users.
		 * When a user tries to login.
		 */
		 foreach ($this->users as $user => $password) {
			 if($tryUser == $user && $tryPassword == $password) {
			 	$_SESSION[$this->m_sessionLoggedIn] = true;
				return true;
			 } else {
			 	// Username doesn't exist
			 	if ($tryUser != $user) {
			 		throw new Exception("The user doesn't exist.", 2002);
			 	} 
			 	// Wrong password.
			 	elseif ($tryPassword != $password) {
			 		throw new Exception("Wrong lösenord", 2003);
			 	}
			 	return false;	
			 }
		 }
	}
	
	
	/**
	 * Loggin out a user
	 */
	public function doLogout() {
		$_SESSION[$this->m_sessionLoggedIn] = false;<commit_msg>wrong user, wrong password => wrong user or passw<commit_after><?php

class LoginHandler{
	private $m_sessionLoggedIn = "loggedIn";
			
	/**
	 * Create temporary Users
	 */
	private $users = array("Fisk" => "Fisk22", "Fisken" => "Fisken22", "Sture" => "Sture22");	
	
	/**
	 * Create a error array
	 */
	public $errors = array();
	
	/**
	 * Any user logged in?
	 * 
	 * @return BOOLEAN, True = logged in, False = not logged in
	 */
	public function isLoggedIn() {
		if($_SESSION[$this->m_sessionLoggedIn]) {
			return true;
		}
		return false;
	}
	
	/**
	 * Logging in a user if the password is right.
	 * 
	 * @param $tryUser String, attempted username
	 * @param $tryPassword String, attempted password
	 * @return Boolean, True = Login success, False = Login Failed.
	 */
	public function doLogin($tryUser, $tryPassword) {
		
		/* 
		 * Creates a test for all users.
		 * When a user tries to login.
		 */
		 foreach ($this->users as $user => $password) {
			 if($tryUser == $user && $tryPassword == $password) {
			 	$_SESSION[$this->m_sessionLoggedIn] = true;
				return true;
			 } else {
			 	// Wrong Username or password
		 		throw new Exception("Wrong username or password", 2002);
			 	return false;	
			 }
		 }
	}
	
	
	/**
	 * Loggin out a user
	 */
	public function doLogout() {
		$_SESSION[$this->m_sessionLoggedIn] = false;
{'fraction_non_alphanumeric': 0.14209019327129563, 'fraction_numerical': 0.008589835361488905, 'mean_word_length': 2.8340192043895747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '3821318', 'n_tokens_mistral': 1074, 'n_tokens_neox': 884, 'n_words': 266}