Ejemplo n.º 1
0
 public function boLogin($datos)
 {
     $msg = new Mensaje();
     $usr = $this->sanearVariables('vacio', $datos->usuario);
     $pass = $this->sanearVariables('vacio', $datos->contrasena);
     if ($usr and $pass) {
         // SATINAR Y CAMPOS VACIOS
         $datos->usuario = $this->sanearVariables('san_string', $datos->usuario);
         //MD5  CONDIFICAR CUANDO SE ENCUENTRE EL REGISTRO DE USUARIOS
         if (!$this->dao->daoLogin($datos)) {
             // DATOS INCORRECTOS
             $msg->msj = '<strong>Advertencia:</strong> Nombre de usuario o contraseña es invalido.';
             $msg->tipo = 'Error';
             return $msg;
         } else {
             // USUARIO CORRECTO
             $inf_usr = $this->dao->verificaRol($datos->usuario);
             // VERIFICA EL ROL EN DB
             if ($this->statusUsuario($inf_usr['status'])) {
                 // VERIFICA STATUS DE USUARIO
                 $msg->pag = 'desabilitado.php';
                 $msg->msj = '<strong>Exito:</strong> Ingresando...';
                 $msg->tipo = 'Exito';
                 return $msg;
             } else {
                 //ASIGNA DIRECCION USR O ADMIN
                 Sessiones::construir_session();
                 $data = array('usuario' => $inf_usr['usuario'], 'rol' => $inf_usr['idrol_usuario']);
                 Sessiones::set_var($data);
                 $usuario = Roles::get_roles($inf_usr['idrol_usuario']);
                 if ($usuario == 'admin') {
                     $msg->pag = 'panel.php';
                     $msg->msj = '<strong>Exito:</strong> Ingresando...';
                     $msg->tipo = 'Exito';
                     return $msg;
                 } else {
                     $msg->pag = 'usr.php';
                     $msg->msj = '<strong>Exito:</strong> Ingresando...';
                     $msg->tipo = 'Exito';
                     return $msg;
                 }
             }
         }
     } else {
         $msg->tipo = 'Vacio';
         $msg->msj = '<strong>Error:</strong> Existen campos vacios.';
         return $msg;
     }
 }
Ejemplo n.º 2
0
 public function acceso()
 {
     if (!isset($_POST['adminmat'])) {
         throw new Exception("Datos incorrectos");
         exit;
     }
     if (!isset($_POST['adminpass'])) {
         throw new Exception("Datos incorrectos");
         exit;
     }
     $matricula = $this->euroval->run('Matricula', $_POST['adminmat'], array('required', 'alpha_numeric'));
     if (is_array($matricula)) {
         foreach ($matricula as $value) {
             throw new Exception($value);
         }
         exit;
     }
     $password = $this->euroval->run('Password', $_POST['adminpass'], array('required', 'alpha_numeric'));
     if (is_array($password)) {
         foreach ($password as $value) {
             throw new Exception($value);
         }
         exit;
     }
     $datos = array('matricula' => $matricula, 'password' => $password);
     $usuario = $this->model->login($datos);
     if (!$usuario) {
         throw new Exception('Su matricula o la contraseña son incorrectas');
     } else {
         if ($usuario['passwordStatus'] != 0) {
             $response = array('msg' => 'Bienvenido al sistema :D', 'status' => 'home', 'url' => 'home');
             echo json_encode($response);
         } else {
             $response = array('msg' => 'Bienvenido al sistema :D', 'status' => 'changepass', 'url' => 'login/changePass');
             echo json_encode($response);
         }
         Sessiones::set_var($usuario);
     }
     //$this->_View->render('login');
 }