<commit_before><?php

/**
 * author: Pholenk
 * email: <EMAIL>
 * github: Pholenk
 */

class Auth extends MX_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('AuthModel');
		$this->load->helper('url');
	}

	public function index()
	{
		if($this->_is_login() === FALSE)
		{
			$this->load->view('login');
		}
		else
		{
			redirect(base_url('users/'));
		}
	}

	/**
	 * login method
	 * create user's session
	 */
	public function login()
	{
		$email = $this->input->post('email');
		$password = $this->input->post('password');
		$query = $this->AuthModel->login($email, $password);
		if(!empty($query))
		{
			$id = $query->id;
			$jabatan = $query->jabatan;
			$nama = $query->name_full;
			if(!empty($id) && !empty($jabatan))
			{
				$data = array(
				'id' => $id,
				'nama' => $nama,
				'jabatan' => $jabatan,
				'logged_in' => TRUE
				);
				$this->session->set_userdata($data);
				echo 'TRUE';
			}
		}
	}

	/**
	 * is_login method
	 * check that user is currently logged in
	 */
	function _is_login()
	{
		return (!empty($this->session->userdata('logged_in')) ? TRUE : FALSE);
		echo($this->session->userdata('logged_in'));
	}

	/**
	 * logout method
	 * destroy user's session
	 */
	public function logout()
	{
		$this->session->unset_userdata('id','jabatan','logged_in');
		session_destroy();
		redirect(base_url());
	}

	/**
	 * privileges_read method
	 * allow or disallow user to access a page
	 */
	public function privileges_read($column)
	{
		if($this->_is_login())
		{
			$id = $this->session->id;
			$query = $this->AuthModel->privileges_read($id, $column);
			return ($query->$column == 1 ? TRUE : FALSE);
		}
		else
		{
			redirect(base_url());
		}
	}

}<commit_msg>change authorization redirect<commit_after><?php

/**
 * author: Pholenk
 * email: <EMAIL>
 * github: Pholenk
 */

class Auth extends MX_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('AuthModel');
		$this->load->helper('url');
	}

	public function index()
	{
		if($this->_is_login() === FALSE)
		{
			$this->load->view('login');
		}
		else
		{
			redirect(base_url('users/'));
		}
	}

	/**
	 * login method
	 * create user's session
	 */
	public function login()
	{
		$email = $this->input->post('email');
		$password = $this->input->post('password');
		$query = $this->AuthModel->login($email, $password);
		if(!empty($query))
		{
			$id = $query->id;
			$jabatan = $query->jabatan;
			$nama = $query->name_full;
			if(!empty($id) && !empty($jabatan))
			{
				$data = array(
				'id' => $id,
				'nama' => $nama,
				'jabatan' => $jabatan,
				'logged_in' => TRUE
				);
				$this->session->set_userdata($data);
				echo 'TRUE';
			}
		}
	}

	/**
	 * is_login method
	 * check that user is currently logged in
	 */
	function _is_login()
	{
		return (!empty($this->session->userdata('logged_in')) ? TRUE : FALSE);
	}

	/**
	 * logout method
	 * destroy user's session
	 */
	public function logout()
	{
		$this->session->unset_userdata('id','jabatan','logged_in');
		session_destroy();
		redirect(base_url());
	}

	/**
	 * privileges_read method
	 * allow or disallow user to access a page
	 */
	public function privileges_read($column)
	{
		$id = $this->session->id;
		$query = $this->AuthModel->privileges_read($id, $column);
		if($this->_is_login() && $query->$column == 1)
		{
			return TRUE;
		}
		elseif ($this->_is_login() && $query->column == 0)
		{
			$this->load->view('head');
			$this->load->view('navbar');
			$this->load->view('Unauthorize');
			$this->load->view('sidebar');
			$this->load->view('foot');
		}
		else
		{
			redirect(base_url());
		}
	}

}
{'fraction_non_alphanumeric': 0.20542317173377156, 'fraction_numerical': 0.0008216926869350862, 'mean_word_length': 3.33729216152019, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 83, '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': '1450746', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1322, 'n_words': 239}