<commit_before><?php
class Auth extends Controller {
 
    function __construct() 
    {
        parent::__construct();
        $this->load->library(array('ion_auth','database','session','form_validation'));
        $this->load->helper('url');
    }
 
    //redirect if needed, otherwise display the user list
    function index() 
    {
    	if (!$this->ion_auth->logged_in()) {
	    	//redirect them to the login page
			redirect("auth/login", 'refresh');
    	}
    	elseif (!$this->ion_auth->is_admin()) {
    		//redirect them to the home page because they must be an administrator to view this
			redirect("/", 'refresh');
    	}
    	else {
	        //set the flash data error message if there is one
	        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
	        
    		//list the users
    		$this->data['users'] = $this->ion_auth->get_users_array();
    		$this->load->view('auth/index', $this->data);
    	}
    }
    
    //log the user in
    function login() 
    {
        $this->data['title'] = "Login";
        
        //validate form input
    	$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
	    $this->form_validation->set_rules('password', 'Password', '<PASSWORD>');

        if ($this->form_validation->run() == true) { //check to see if the user is logging in
        	if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'))) { //if the login is successful
	        	//redirect them back to the home page
	        	$this->session->set_flashdata('message', "Logged In Successfully");
	        	redirect('/', 'refresh');
	        }
	        else { //if the login was un-successful
	        	//redirect them back to the login page
	        	$this->session->set_flashdata('message', "Login In-Correct");
	        	redirect("auth/login", 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
	        }
        }
		else {  //the user is not logging in so display the login page
	        //set the flash data error message if there is one
	        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
		    
			$this->data['email']      = array('name'    => 'email',
                                              'id'      => 'email',
                                              'type'    => 'text',
                                              'value'   => $this->form_validation->set_value('email'),
                                             );
            $this->data['password']   = array('name'    => 'password',
                                              'id'      => 'password',
                                              'type'    => 'password',
                                             );
	        <commit_msg>Using base_url in redirects instead of '/'<commit_after><?php
class Auth extends Controller {
 
    function __construct() 
    {
        parent::__construct();
        $this->load->library(array('ion_auth','database','session','form_validation'));
        $this->load->helper('url');
    }
 
    //redirect if needed, otherwise display the user list
    function index() 
    {
    	if (!$this->ion_auth->logged_in()) {
	    	//redirect them to the login page
			redirect("auth/login", 'refresh');
    	}
    	elseif (!$this->ion_auth->is_admin()) {
    		//redirect them to the home page because they must be an administrator to view this
			redirect($this->config->item('base_url'), 'refresh');
    	}
    	else {
	        //set the flash data error message if there is one
	        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
	        
    		//list the users
    		$this->data['users'] = $this->ion_auth->get_users_array();
    		$this->load->view('auth/index', $this->data);
    	}
    }
    
    //log the user in
    function login() 
    {
        $this->data['title'] = "Login";
        
        //validate form input
    	$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
	    $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == true) { //check to see if the user is logging in
        	if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'))) { //if the login is successful
	        	//redirect them back to the home page
	        	$this->session->set_flashdata('message', "Logged In Successfully");
	        	redirect($this->config->item('base_url'), 'refresh');
	        }
	        else { //if the login was un-successful
	        	//redirect them back to the login page
	        	$this->session->set_flashdata('message', "Login In-Correct");
	        	redirect("auth/login", 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
	        }
        }
		else {  //the user is not logging in so display the login page
	        //set the flash data error message if there is one
	        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
		    
			$this->data['email']      = array('name'    => 'email',
                                              'id'      => 'email',
                                              'type'    => 'text',
                                              'value'   => $this->form_validation->set_value('email'),
                                             );
            $this->data['password']   = array('name'    => 'password',
                                              'id'      => 'password',
                                              'type'    => 'password',
                                             );
	        
{'fraction_non_alphanumeric': 0.14792697491895582, 'fraction_numerical': 0.0, 'mean_word_length': 1.829150579150579, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 104, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4366777', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1490, 'n_words': 392}