<commit_before><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Login_model extends CI_Model {

	    function __construct(){        
	        parent::__construct();
     
	    }
	    
	    /**
	     * Valida los datos del formulario de ingreso (login y password) contra la base de datos del aplicativo
	     * @author BMOTTAG
	     * @since  8/11/2016
	     */
	    public function validateLogin($arrData)
		{
	    	$user = array();
	    	$user["valid"] = false;
			
	    	$login = str_replace(array("<",">","[","]","*","^","-","'","="),"",$arrData["login"]);   
	    	$passwd = str_replace(array("<",">","[","]","*","^","-","'","="),"",$arrData["passwd"]); 
			$passwd = <PASSWORD>($passwd);
			
	    	$sql = "SELECT * FROM usuario WHERE log_user = '$login' and password = '$<PASSWORD>'";
	    	$query = $this->db->query($sql);

	    	if ($query->num_rows() > 0){	    		
	    		foreach($query->result() as $row)
				{
	    				$user["valid"] = true;
	    				$user["id"] = $row->id_usuario;
	    				$user["firstname"] = $row->nombres_usuario;
	    				$user["lastname"] = $row->apellidos_usuario;
						$user["logUser"] = $row->log_user;
	    				$user["movil"] = $row->celular;
						$user["state"] = $row->estado;
						$user["rol"] = $row->fk_id_rol;
	    		}
	    	}
			
	    	$this->db->close();	    	
	    	return $user;
	    }
		
	    /**
	     * Redirecciona el usuario al módulo correspondiente dependiendo de los datos almacenados en la session
	     * @author BMOTTAG
	     * @since  8/11/2016
		 * @review  18/12/2016
	     */
	    public function redireccionarUsuario()
		{
			$state = $this->session->userdata("state");
			$userRol = $this->session->userdata("rol");

	    	switch($state){
	    		case 0: //NEW USER, must change the password
	    				redirect("/employee","location",301);
	    				break;
	    		case 1: //ACTIVE USER
						if($userRol==4){//vista para delegados
							redirect("/dashboard/delegados","location",301);
						}else{
							redirect("/dashboard","location",301);
						}
	    				break;
	    		case 2: //INACTIVE USER
	    				$this->session->sess_destroy();
	    				redirect("/login","location",301);
	    				break;
	    		default: //No sé como llegaron hasta acá, pero los devuelvo al Login.
	    				$this->session->sess_destroy();
	    				redirect("/login","location",301);
	    				break;
	    	}
	    }<commit_msg>Login: Se adiciona redirecconamiento para los coordinadres<commit_after><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Login_model extends CI_Model {

	    function __construct(){        
	        parent::__construct();
     
	    }
	    
	    /**
	     * Valida los datos del formulario de ingreso (login y password) contra la base de datos del aplicativo
	     * @author BMOTTAG
	     * @since  8/11/2016
	     */
	    public function validateLogin($arrData)
		{
	    	$user = array();
	    	$user["valid"] = false;
			
	    	$login = str_replace(array("<",">","[","]","*","^","-","'","="),"",$arrData["login"]);   
	    	$passwd = str_replace(array("<",">","[","]","*","^","-","'","="),"",$arrData["passwd"]); 
			$passwd = md5($passwd);
			
	    	$sql = "SELECT * FROM usuario WHERE log_user = '$login' and password = '$<PASSWORD>'";
	    	$query = $this->db->query($sql);

	    	if ($query->num_rows() > 0){	    		
	    		foreach($query->result() as $row)
				{
	    				$user["valid"] = true;
	    				$user["id"] = $row->id_usuario;
	    				$user["firstname"] = $row->nombres_usuario;
	    				$user["lastname"] = $row->apellidos_usuario;
						$user["logUser"] = $row->log_user;
	    				$user["movil"] = $row->celular;
						$user["state"] = $row->estado;
						$user["rol"] = $row->fk_id_rol;
	    		}
	    	}
			
	    	$this->db->close();	    	
	    	return $user;
	    }
		
	    /**
	     * Redirecciona el usuario al módulo correspondiente dependiendo de los datos almacenados en la session
	     * @author BMOTTAG
	     * @since  8/11/2016
		 * @review  18/12/2016
	     */
	    public function redireccionarUsuario()
		{
			$state = $this->session->userdata("state");
			$userRol = $this->session->userdata("rol");

	    	switch($state){
	    		case 0: //NEW USER, must change the password
	    				redirect("/employee","location",301);
	    				break;
	    		case 1: //ACTIVE USER
						if($userRol==4){//vista para delegados
							redirect("/dashboard/delegados","location",301);
						}elseif($userRol==3){//vista para coordinadores
							redirect("/dashboard/coordinadores","location",301);
						}else{
							redirect("/dashboard","location",301);
						}
	    				break;
	    		case 2: //INACTIVE USER
	    				$this->session->sess_destroy();
	    				redirect("/login","location",301);
	    				break;
	    		default: //No sé como llegaron hasta acá, pero los devuelvo al Login.
	    				$this->session->sess_destroy();
	    				redirect("/login","location",301);
	    				break;
	    	}
	    }
{'fraction_non_alphanumeric': 0.1844758064516129, 'fraction_numerical': 0.017943548387096775, 'mean_word_length': 2.3886612021857925, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 54, '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': '7142982', 'n_tokens_mistral': 2044, 'n_tokens_neox': 1690, 'n_words': 324}